Skip to content
This repository was archived by the owner on Jan 19, 2025. It is now read-only.

Commit 5fc20e3

Browse files
authored
refactor: use TypeScript parameter properties (#472)
* refactor: use TypeScript parameter properties * style: apply automatic fixes of linters * refactor: use TypeScript parameter properties (2) * style: apply automatic fixes of linters Co-authored-by: lars-reimann <[email protected]>
1 parent 78eb327 commit 5fc20e3

14 files changed

+93
-264
lines changed

api-editor/client/src/features/annotatedPackageData/model/AnnotatedPythonClass.ts

+10-30
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,15 @@ import { InferableAnnotation } from './InferableAnnotation';
22
import AnnotatedPythonFunction from './AnnotatedPythonFunction';
33

44
export default class AnnotatedPythonClass {
5-
readonly name: string;
6-
readonly qualifiedName: string;
7-
readonly decorators: string[];
8-
readonly superclasses: string[];
9-
readonly methods: AnnotatedPythonFunction[];
10-
readonly isPublic: boolean;
11-
readonly description: string;
12-
readonly fullDocstring: string;
13-
readonly annotations: InferableAnnotation[];
14-
155
constructor(
16-
name: string,
17-
qualifiedName: string,
18-
decorators: string[] = [],
19-
superclasses: string[] = [],
20-
methods: AnnotatedPythonFunction[] = [],
21-
isPublic: boolean = true,
22-
description: string = '',
23-
fullDocstring: string = '',
24-
annotations: InferableAnnotation[] = [],
25-
) {
26-
this.name = name;
27-
this.qualifiedName = qualifiedName;
28-
this.decorators = decorators;
29-
this.superclasses = superclasses;
30-
this.methods = methods;
31-
this.isPublic = isPublic;
32-
this.description = description;
33-
this.fullDocstring = fullDocstring;
34-
this.annotations = annotations;
35-
}
6+
readonly name: string,
7+
readonly qualifiedName: string,
8+
readonly decorators: string[] = [],
9+
readonly superclasses: string[] = [],
10+
readonly methods: AnnotatedPythonFunction[] = [],
11+
readonly isPublic: boolean = true,
12+
readonly description: string = '',
13+
readonly fullDocstring: string = '',
14+
readonly annotations: InferableAnnotation[] = [],
15+
) {}
3616
}

api-editor/client/src/features/annotatedPackageData/model/AnnotatedPythonFunction.ts

+10-30
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,15 @@ import AnnotatedPythonParameter from './AnnotatedPythonParameter';
33
import AnnotatedPythonResult from './AnnotatedPythonResult';
44

55
export default class AnnotatedPythonFunction {
6-
readonly name: string;
7-
readonly qualifiedName: string;
8-
readonly decorators: string[];
9-
readonly parameters: AnnotatedPythonParameter[];
10-
readonly results: AnnotatedPythonResult[];
11-
readonly isPublic: boolean;
12-
readonly description: string;
13-
readonly fullDocstring: string;
14-
readonly annotations: InferableAnnotation[];
15-
166
constructor(
17-
name: string,
18-
qualifiedName: string,
19-
decorators: string[] = [],
20-
parameters: AnnotatedPythonParameter[] = [],
21-
results: AnnotatedPythonResult[] = [],
22-
isPublic: boolean = false,
23-
description: string = '',
24-
fullDocstring: string = '',
25-
annotations: InferableAnnotation[] = [],
26-
) {
27-
this.name = name;
28-
this.qualifiedName = qualifiedName;
29-
this.decorators = decorators;
30-
this.parameters = parameters;
31-
this.results = results;
32-
this.isPublic = isPublic;
33-
this.description = description;
34-
this.fullDocstring = fullDocstring;
35-
this.annotations = annotations;
36-
}
7+
readonly name: string,
8+
readonly qualifiedName: string,
9+
readonly decorators: string[] = [],
10+
readonly parameters: AnnotatedPythonParameter[] = [],
11+
readonly results: AnnotatedPythonResult[] = [],
12+
readonly isPublic: boolean = false,
13+
readonly description: string = '',
14+
readonly fullDocstring: string = '',
15+
readonly annotations: InferableAnnotation[] = [],
16+
) {}
3717
}

api-editor/client/src/features/annotatedPackageData/model/AnnotatedPythonModule.ts

+7-21
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,12 @@ import AnnotatedPythonClass from './AnnotatedPythonClass';
55
import AnnotatedPythonFunction from './AnnotatedPythonFunction';
66

77
export default class AnnotatedPythonModule {
8-
readonly name: string;
9-
readonly imports: PythonImport[];
10-
readonly fromImports: PythonFromImport[];
11-
readonly classes: AnnotatedPythonClass[];
12-
readonly functions: AnnotatedPythonFunction[];
13-
readonly annotations: InferableAnnotation[];
14-
158
constructor(
16-
name: string,
17-
imports: PythonImport[] = [],
18-
fromImports: PythonFromImport[] = [],
19-
classes: AnnotatedPythonClass[] = [],
20-
functions: AnnotatedPythonFunction[] = [],
21-
annotations: InferableAnnotation[] = [],
22-
) {
23-
this.name = name;
24-
this.imports = imports;
25-
this.fromImports = fromImports;
26-
this.classes = classes;
27-
this.functions = functions;
28-
this.annotations = annotations;
29-
}
9+
readonly name: string,
10+
readonly imports: PythonImport[] = [],
11+
readonly fromImports: PythonFromImport[] = [],
12+
readonly classes: AnnotatedPythonClass[] = [],
13+
readonly functions: AnnotatedPythonFunction[] = [],
14+
readonly annotations: InferableAnnotation[] = [],
15+
) {}
3016
}

api-editor/client/src/features/annotatedPackageData/model/AnnotatedPythonPackage.ts

+6-18
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,11 @@ import { InferableAnnotation } from './InferableAnnotation';
22
import AnnotatedPythonModule from './AnnotatedPythonModule';
33

44
export default class AnnotatedPythonPackage {
5-
readonly distribution: string;
6-
readonly name: string;
7-
readonly version: string;
8-
readonly modules: AnnotatedPythonModule[];
9-
readonly annotations: InferableAnnotation[];
10-
115
constructor(
12-
distribution: string,
13-
name: string,
14-
version: string,
15-
modules: AnnotatedPythonModule[] = [],
16-
annotations: InferableAnnotation[] = [],
17-
) {
18-
this.distribution = distribution;
19-
this.name = name;
20-
this.version = version;
21-
this.modules = modules;
22-
this.annotations = annotations;
23-
}
6+
readonly distribution: string,
7+
readonly name: string,
8+
readonly version: string,
9+
readonly modules: AnnotatedPythonModule[] = [],
10+
readonly annotations: InferableAnnotation[] = [],
11+
) {}
2412
}
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,11 @@
11
import { InferableAnnotation } from './InferableAnnotation';
22

33
export default class AnnotatedPythonResult {
4-
readonly name: string;
5-
readonly type: string;
6-
readonly typeInDocs: string;
7-
readonly description: string;
8-
readonly annotations: InferableAnnotation[];
9-
104
constructor(
11-
name: string,
12-
type: string = 'Any',
13-
typeInDocs: string = '',
14-
description: string = '',
15-
annotations: InferableAnnotation[] = [],
16-
) {
17-
this.name = name;
18-
this.type = type;
19-
this.typeInDocs = typeInDocs;
20-
this.description = description;
21-
this.annotations = annotations;
22-
}
5+
readonly name: string,
6+
readonly type: string = 'Any',
7+
readonly typeInDocs: string = '',
8+
readonly description: string = '',
9+
readonly annotations: InferableAnnotation[] = [],
10+
) {}
2311
}

api-editor/client/src/features/packageData/model/PythonClass.ts

+8-24
Original file line numberDiff line numberDiff line change
@@ -6,36 +6,20 @@ import PythonFunction from './PythonFunction';
66
import PythonModule from './PythonModule';
77

88
export default class PythonClass extends PythonDeclaration {
9-
readonly name: string;
10-
readonly qualifiedName: string;
11-
readonly decorators: string[];
12-
readonly superclasses: string[];
13-
readonly methods: PythonFunction[];
14-
readonly isPublic: boolean;
15-
readonly description: string;
16-
readonly fullDocstring: string;
179
containingModule: Optional<PythonModule>;
1810

1911
constructor(
20-
name: string,
21-
qualifiedName: string,
22-
decorators: string[] = [],
23-
superclasses: string[] = [],
24-
methods: PythonFunction[] = [],
25-
isPublic: boolean = true,
26-
description = '',
27-
fullDocstring = '',
12+
readonly name: string,
13+
readonly qualifiedName: string,
14+
readonly decorators: string[] = [],
15+
readonly superclasses: string[] = [],
16+
readonly methods: PythonFunction[] = [],
17+
readonly isPublic: boolean = true,
18+
readonly description = '',
19+
readonly fullDocstring = '',
2820
) {
2921
super();
3022

31-
this.name = name;
32-
this.qualifiedName = qualifiedName;
33-
this.decorators = decorators;
34-
this.superclasses = superclasses;
35-
this.methods = methods;
36-
this.isPublic = isPublic;
37-
this.description = description;
38-
this.fullDocstring = fullDocstring;
3923
this.containingModule = null;
4024

4125
this.methods.forEach((it) => {

api-editor/client/src/features/packageData/model/PythonFilter.ts

+5-15
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,12 @@
11
export type FilterString = string;
22

33
export class PythonFilter {
4-
readonly pythonModule: FilterString | void;
5-
readonly pythonClass: FilterString | void;
6-
readonly pythonFunction: FilterString | void;
7-
readonly pythonParameter: FilterString | void;
8-
94
constructor(
10-
pythonModule: FilterString | void,
11-
pythonClass: FilterString | void,
12-
pythonFunction: FilterString | void,
13-
pythonParameter: FilterString | void,
14-
) {
15-
this.pythonModule = pythonModule;
16-
this.pythonClass = pythonClass;
17-
this.pythonFunction = pythonFunction;
18-
this.pythonParameter = pythonParameter;
19-
}
5+
readonly pythonModule: FilterString | void,
6+
readonly pythonClass: FilterString | void,
7+
readonly pythonFunction: FilterString | void,
8+
readonly pythonParameter: FilterString | void,
9+
) {}
2010

2111
static fromFilterBoxInput(filterBoxInput: string): PythonFilter | void {
2212
let pythonModule;

api-editor/client/src/features/packageData/model/PythonFromImport.ts

+4-12
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,11 @@
11
import { Optional } from '../../../common/util/types';
22

33
export default class PythonFromImport {
4-
readonly module: string;
5-
readonly declaration: string;
6-
readonly alias: Optional<string>;
7-
84
constructor(
9-
module: string,
10-
declaration: string,
11-
alias: Optional<string> = null,
12-
) {
13-
this.module = module;
14-
this.declaration = declaration;
15-
this.alias = alias;
16-
}
5+
readonly module: string,
6+
readonly declaration: string,
7+
readonly alias: Optional<string> = null,
8+
) {}
179

1810
toString(): string {
1911
if (this.alias === null) {

api-editor/client/src/features/packageData/model/PythonFunction.ts

+10-30
Original file line numberDiff line numberDiff line change
@@ -7,42 +7,22 @@ import PythonParameter from './PythonParameter';
77
import PythonResult from './PythonResult';
88

99
export default class PythonFunction extends PythonDeclaration {
10-
readonly name: string;
11-
readonly uniqueName: string;
12-
readonly qualifiedName: string;
13-
readonly uniqueQualifiedName: string;
14-
readonly decorators: string[];
15-
readonly parameters: PythonParameter[];
16-
readonly results: PythonResult[];
17-
readonly isPublic: boolean;
18-
readonly description: string;
19-
readonly fullDocstring: string;
2010
containingModuleOrClass: Optional<PythonModule | PythonClass>;
2111

2212
constructor(
23-
name: string,
24-
uniqueName: string,
25-
qualifiedName: string,
26-
uniqueQualifiedName: string,
27-
decorators: string[] = [],
28-
parameters: PythonParameter[] = [],
29-
results: PythonResult[] = [],
30-
isPublic: boolean = false,
31-
description = '',
32-
fullDocstring = '',
13+
readonly name: string,
14+
readonly uniqueName: string,
15+
readonly qualifiedName: string,
16+
readonly uniqueQualifiedName: string,
17+
readonly decorators: string[] = [],
18+
readonly parameters: PythonParameter[] = [],
19+
readonly results: PythonResult[] = [],
20+
readonly isPublic: boolean = false,
21+
readonly description = '',
22+
readonly fullDocstring = '',
3323
) {
3424
super();
3525

36-
this.name = name;
37-
this.uniqueName = uniqueName;
38-
this.qualifiedName = qualifiedName;
39-
this.uniqueQualifiedName = uniqueQualifiedName;
40-
this.decorators = decorators;
41-
this.parameters = parameters;
42-
this.results = results;
43-
this.isPublic = isPublic;
44-
this.description = description;
45-
this.fullDocstring = fullDocstring;
4626
this.containingModuleOrClass = null;
4727

4828
this.parameters.forEach((it) => {

api-editor/client/src/features/packageData/model/PythonImport.ts

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
import { Optional } from '../../../common/util/types';
22

33
export default class PythonImport {
4-
readonly module: string;
5-
readonly alias: Optional<string>;
6-
7-
constructor(module: string, alias: Optional<string> = null) {
8-
this.module = module;
9-
this.alias = alias;
10-
}
4+
constructor(
5+
readonly module: string,
6+
readonly alias: Optional<string> = null,
7+
) {}
118

129
toString(): string {
1310
if (this.alias === null) {

api-editor/client/src/features/packageData/model/PythonModule.ts

+5-15
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,17 @@ import PythonImport from './PythonImport';
99
import PythonPackage from './PythonPackage';
1010

1111
export default class PythonModule extends PythonDeclaration {
12-
readonly name: string;
13-
readonly imports: PythonImport[];
14-
readonly fromImports: PythonFromImport[];
15-
readonly classes: PythonClass[];
16-
readonly functions: PythonFunction[];
1712
containingPackage: Optional<PythonPackage>;
1813

1914
constructor(
20-
name: string,
21-
imports: PythonImport[] = [],
22-
fromImports: PythonFromImport[] = [],
23-
classes: PythonClass[] = [],
24-
functions: PythonFunction[] = [],
15+
readonly name: string,
16+
readonly imports: PythonImport[] = [],
17+
readonly fromImports: PythonFromImport[] = [],
18+
readonly classes: PythonClass[] = [],
19+
readonly functions: PythonFunction[] = [],
2520
) {
2621
super();
2722

28-
this.name = name;
29-
this.imports = imports;
30-
this.fromImports = fromImports;
31-
this.classes = classes;
32-
this.functions = functions;
3323
this.containingPackage = null;
3424

3525
this.classes.forEach((it) => {

0 commit comments

Comments
 (0)