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

Commit 6b5a74d

Browse files
lukaradenvollroth
andcommitted
Typisierung hinzugefügt
Typisierung hinzugefügt, Schnittstelle über __init__ definiert, Kommentare bearbeitet Co-Authored-By: nvollroth <[email protected]>
1 parent 07a658b commit 6b5a74d

File tree

3 files changed

+13
-15
lines changed

3 files changed

+13
-15
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from ._combine import write_json

package-parser/package_parser/commands/generate_annotations/combine.py renamed to package-parser/package_parser/commands/generate_annotations/_combine.py

+10-13
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import os
44

55

6-
def write_json(output_path, constant_path, unused_path):
6+
def write_json(output_path: str, constant_path: str, unused_path: str) -> None:
77
"""
88
Dient zum Mergen von Unused-Dictionary und Constant-Dictionary und anschließende Erzeugen einer JSON - File,
99
die das erzeugte Dictionary beinhaltet.
@@ -15,6 +15,7 @@ def write_json(output_path, constant_path, unused_path):
1515
# Platzhalter für echte Funktion
1616
# unused_dict = find_unused(unused_path)
1717

18+
# entfernen, wenn Funktion aus Issue 433 fertig
1819
unused_dict = {
1920
"sklearn/sklearn.__check_build/raise_build_error": {
2021
"target": "sklearn/sklearn.__check_build/raise_build_error"
@@ -23,6 +24,7 @@ def write_json(output_path, constant_path, unused_path):
2324
# Platzhalter für echte Funktion
2425
# constant_dict = find_constant(constant_path)
2526

27+
# entfernen, wenn Funktion aus Issue 434 fertig
2628
constant_dict = {
2729
"sklearn/sklearn._config/config_context/assume_finite": {
2830
"target": "sklearn/sklearn._config/config_context/assume_finite",
@@ -45,22 +47,17 @@ def write_json(output_path, constant_path, unused_path):
4547
"defaultValue": "3",
4648
},
4749
}
48-
result_dict = combine_dictionaries(unused_dict, constant_dict)
49-
50-
# result_dict = combine_dictionaries(module.unusedDictFunction, module.constantDictFunction)
51-
# als 2 Parameter können die Rückgabewerte der Funktionen, die die jw. gefragten Dictionaries sind
52-
# eingesetzt werden; derzeit in Bearbeitung
50+
result_dict = __combine_dictionaries(unused_dict, constant_dict)
5351

5452
with open(os.path.join(output_path, "annotations.json"), "w") as file:
55-
# with open(f"{output_path}\\annotations.json", "w") as file:
5653
json.dump(
5754
result_dict,
5855
file,
5956
indent=2,
6057
)
6158

6259

63-
def combine_dictionaries(unused_dict, constant_dict):
60+
def __combine_dictionaries(unused_dict: dict, constant_dict: dict) -> dict:
6461
"""
6562
Funktion, die die Dictionaries kombiniert
6663
:param unused_dict : Dictionary der unused annotations
@@ -75,31 +72,31 @@ def combine_dictionaries(unused_dict, constant_dict):
7572
return result_dict
7673

7774

75+
# sollte, sobald final eingebunden wird entfernt werden, da es nicht weiter benötigt wird, dient zZ. nur zur Anschauung
7876
if __name__ == "__main__":
7977
parser = argparse.ArgumentParser(prog="combine")
8078

79+
# Argument 1: outputPath
8180
parser.add_argument(
8281
"outputPath",
8382
metavar="output-filepath",
8483
type=str,
8584
help="paste the location of the output file in here ",
8685
)
87-
# Argument 1: outputPath
86+
# Argument 2: inputPath(Pfad einer Constant-Datei)
8887
parser.add_argument(
8988
"constantPath",
9089
metavar="input-filepath",
9190
type=str,
9291
help='paste the location of the "constant" file in here ',
9392
)
94-
# Argument 2: inputPath(Pfad einer Constant-Datei)
93+
# Argument 3: inputPath(Pfad einer Unused-Datei)
9594
parser.add_argument(
9695
"unusedPath",
9796
metavar="input-filepath",
9897
type=str,
9998
help='paste the location of the "unused" file in here ',
10099
)
101-
# Argument 3: inputPath(Pfad einer Unused-Datei)
100+
# Erzeuge kombinierte JSON-Datei jeweils aus der Constant- und der Unused-Dictionary
102101
args = parser.parse_args() # Argumente werden auf Nutzen als Parameter vorbereitet
103102
write_json(args.outputPath, args.constantPath, args.unusedPath)
104-
105-
# Erzeuge kombinierte JSON-Datei jw. aus der Constant- und der Unused-Dictionary

package-parser/tests/commands/generate_annotations/test_combine.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import json
22
import os
33

4-
import package_parser.commands.generate_annotations.combine as comb
4+
import package_parser.commands.generate_annotations as comb
55
import pytest
66

77
test_unused_dict = {
@@ -78,5 +78,5 @@ def test_combine_dictionaries(test_unused, test_constant, expected):
7878
:param expected: gemergte JSON-Datei aus den 2 Dictionaries, die entsteht
7979
"""
8080

81-
eval_dict = comb.combine_dictionaries(test_unused, test_constant)
81+
eval_dict = comb.__combine_dictionaries(test_unused, test_constant)
8282
assert eval_dict == expected

0 commit comments

Comments
 (0)