From 0024ce0d1431e6ee4caaa02949514d8adf36b25e Mon Sep 17 00:00:00 2001
From: Sam Pinkus <sgpinkus@gmail.com>
Date: Wed, 8 Jan 2025 16:09:52 +1000
Subject: [PATCH] Readability improvement: Move CacheDistributor constructor
 params to readonly abstract fields of concrete cache implementations. Remove
 empty CacheDistributor constructor.

---
 src/cache-distributions/cache-distributor.ts | 6 ++----
 src/cache-distributions/pip-cache.ts         | 5 +++--
 src/cache-distributions/pipenv-cache.ts      | 6 ++++--
 src/cache-distributions/poetry-cache.ts      | 7 +++++--
 4 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/src/cache-distributions/cache-distributor.ts b/src/cache-distributions/cache-distributor.ts
index 211946fb..55a5a3d6 100644
--- a/src/cache-distributions/cache-distributor.ts
+++ b/src/cache-distributions/cache-distributor.ts
@@ -10,10 +10,8 @@ export enum State {
 
 abstract class CacheDistributor {
   protected CACHE_KEY_PREFIX = 'setup-python';
-  constructor(
-    protected packageManager: string,
-    protected cacheDependencyPath: string
-  ) {}
+  protected abstract readonly packageManager: string;
+  protected abstract readonly cacheDependencyPath: string;
 
   protected abstract getCacheGlobalDirectories(): Promise<string[]>;
   protected abstract computeKeys(): Promise<{
diff --git a/src/cache-distributions/pip-cache.ts b/src/cache-distributions/pip-cache.ts
index d64ae931..c1c9d022 100644
--- a/src/cache-distributions/pip-cache.ts
+++ b/src/cache-distributions/pip-cache.ts
@@ -12,12 +12,13 @@ import {CACHE_DEPENDENCY_BACKUP_PATH} from './constants';
 
 class PipCache extends CacheDistributor {
   private cacheDependencyBackupPath: string = CACHE_DEPENDENCY_BACKUP_PATH;
+  protected readonly packageManager = 'pip';
 
   constructor(
     private pythonVersion: string,
-    cacheDependencyPath = '**/requirements.txt'
+    protected readonly cacheDependencyPath = '**/requirements.txt'
   ) {
-    super('pip', cacheDependencyPath);
+    super();
   }
 
   protected async getCacheGlobalDirectories() {
diff --git a/src/cache-distributions/pipenv-cache.ts b/src/cache-distributions/pipenv-cache.ts
index 79674c20..978f63f7 100644
--- a/src/cache-distributions/pipenv-cache.ts
+++ b/src/cache-distributions/pipenv-cache.ts
@@ -6,11 +6,13 @@ import * as core from '@actions/core';
 import CacheDistributor from './cache-distributor';
 
 class PipenvCache extends CacheDistributor {
+  protected readonly packageManager = 'pipenv';
+
   constructor(
     private pythonVersion: string,
-    protected cacheDependencyPath: string = '**/Pipfile.lock'
+    protected readonly cacheDependencyPath: string = '**/Pipfile.lock'
   ) {
-    super('pipenv', cacheDependencyPath);
+    super();
   }
 
   protected async getCacheGlobalDirectories() {
diff --git a/src/cache-distributions/poetry-cache.ts b/src/cache-distributions/poetry-cache.ts
index 90739dbc..1baffafd 100644
--- a/src/cache-distributions/poetry-cache.ts
+++ b/src/cache-distributions/poetry-cache.ts
@@ -8,12 +8,15 @@ import CacheDistributor from './cache-distributor';
 import {logWarning} from '../utils';
 
 class PoetryCache extends CacheDistributor {
+  protected readonly packageManager = 'poetry';
+
+
   constructor(
     private pythonVersion: string,
-    protected cacheDependencyPath: string = '**/poetry.lock',
+    protected readonly cacheDependencyPath: string = '**/poetry.lock',
     protected poetryProjects: Set<string> = new Set<string>()
   ) {
-    super('poetry', cacheDependencyPath);
+    super();
   }
 
   protected async getCacheGlobalDirectories() {