Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 0024ce0

Browse files
committedFeb 19, 2025
Readability improvement: Move CacheDistributor constructor params to readonly abstract fields of concrete cache implementations. Remove empty CacheDistributor constructor.
1 parent 1f3a570 commit 0024ce0

File tree

4 files changed

+14
-10
lines changed

4 files changed

+14
-10
lines changed
 

‎src/cache-distributions/cache-distributor.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@ export enum State {
1010

1111
abstract class CacheDistributor {
1212
protected CACHE_KEY_PREFIX = 'setup-python';
13-
constructor(
14-
protected packageManager: string,
15-
protected cacheDependencyPath: string
16-
) {}
13+
protected abstract readonly packageManager: string;
14+
protected abstract readonly cacheDependencyPath: string;
1715

1816
protected abstract getCacheGlobalDirectories(): Promise<string[]>;
1917
protected abstract computeKeys(): Promise<{

‎src/cache-distributions/pip-cache.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@ import {CACHE_DEPENDENCY_BACKUP_PATH} from './constants';
1212

1313
class PipCache extends CacheDistributor {
1414
private cacheDependencyBackupPath: string = CACHE_DEPENDENCY_BACKUP_PATH;
15+
protected readonly packageManager = 'pip';
1516

1617
constructor(
1718
private pythonVersion: string,
18-
cacheDependencyPath = '**/requirements.txt'
19+
protected readonly cacheDependencyPath = '**/requirements.txt'
1920
) {
20-
super('pip', cacheDependencyPath);
21+
super();
2122
}
2223

2324
protected async getCacheGlobalDirectories() {

‎src/cache-distributions/pipenv-cache.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ import * as core from '@actions/core';
66
import CacheDistributor from './cache-distributor';
77

88
class PipenvCache extends CacheDistributor {
9+
protected readonly packageManager = 'pipenv';
10+
911
constructor(
1012
private pythonVersion: string,
11-
protected cacheDependencyPath: string = '**/Pipfile.lock'
13+
protected readonly cacheDependencyPath: string = '**/Pipfile.lock'
1214
) {
13-
super('pipenv', cacheDependencyPath);
15+
super();
1416
}
1517

1618
protected async getCacheGlobalDirectories() {

‎src/cache-distributions/poetry-cache.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,15 @@ import CacheDistributor from './cache-distributor';
88
import {logWarning} from '../utils';
99

1010
class PoetryCache extends CacheDistributor {
11+
protected readonly packageManager = 'poetry';
12+
13+
1114
constructor(
1215
private pythonVersion: string,
13-
protected cacheDependencyPath: string = '**/poetry.lock',
16+
protected readonly cacheDependencyPath: string = '**/poetry.lock',
1417
protected poetryProjects: Set<string> = new Set<string>()
1518
) {
16-
super('poetry', cacheDependencyPath);
19+
super();
1720
}
1821

1922
protected async getCacheGlobalDirectories() {

0 commit comments

Comments
 (0)
Please sign in to comment.