Skip to content

Commit 6986528

Browse files
committed
wip: full typing with mypy
1 parent f4a83c1 commit 6986528

File tree

6 files changed

+12
-11
lines changed

6 files changed

+12
-11
lines changed

cmake_file_api/kinds/cache/v2.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,15 @@ def __init__(self, version: VersionMajorMinor, entries: List[CacheEntry]):
7575
self.entries = entries
7676

7777
@classmethod
78-
def from_dict(cls, dikt: Dict, reply_path) -> "CacheModelV2":
78+
def from_dict(cls, dikt: Dict, reply_path) -> "CacheV2":
7979
if dikt["kind"] != cls.KIND.value:
8080
raise ValueError
8181
version = VersionMajorMinor.from_dict(dikt["version"])
8282
entries = list(CacheEntry.from_dict(ce) for ce in dikt["entries"])
8383
return cls(version, entries)
8484

8585
@classmethod
86-
def from_path(cls, path: Path, reply_path: Path) -> "CacheModelV2":
86+
def from_path(cls, path: Path, reply_path: Path) -> "CacheV2":
8787
dikt = json.load(path.open())
8888
return cls.from_dict(dikt, reply_path)
8989

cmake_file_api/kinds/cmakeFiles/v1.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def __init__(self, path: Path, isGenerator: Optional[bool], isExternal: Optional
1616
self.isCMake = isCMake
1717

1818
@classmethod
19-
def from_dict(cls, dikt: Dict) -> "CMakeFileInput":
19+
def from_dict(cls, dikt: Dict) -> "CMakeFilesInput":
2020
path = Path(dikt["path"])
2121
isGenerator = dikt.get("isGenerator")
2222
isExternal = dikt.get("isExternal")

cmake_file_api/kinds/codemodel/target/v2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ def __init__(self, commandFragments: List[TargetArchiveFragment], lto: Optional[
206206
def from_dict(cls, dikt: Dict) -> "TargetArchive":
207207
commandFragments = []
208208
if "commandFragments" in dikt:
209-
commandFragments = list(TargetLinkFragment.from_dict(tlf) for tlf in dikt["commandFragments"])
209+
commandFragments = list(TargetArchiveFragment.from_dict(tlf) for tlf in dikt["commandFragments"])
210210
lto = dikt.get("lto")
211211
return cls(commandFragments, lto)
212212

cmake_file_api/kinds/configureLog/target/v2.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class BacktraceGraph(object):
6161
__slots__ = ("nodes", )
6262

6363
def __init__(self, nodes: List[BacktraceNode]):
64-
self.nodes = nodes
64+
self.nodes: List[BacktraceNode] = nodes
6565

6666
@classmethod
6767
def from_dict(cls, dikt: Dict) -> "BacktraceGraph":
@@ -205,7 +205,7 @@ def __init__(self, commandFragments: List[TargetArchiveFragment], lto: Optional[
205205
def from_dict(cls, dikt: Dict) -> "TargetArchive":
206206
commandFragments = []
207207
if "commandFragments" in dikt:
208-
commandFragments = list(TargetLinkFragment.from_dict(tlf) for tlf in dikt["commandFragments"])
208+
commandFragments = list(TargetArchiveFragment.from_dict(tlf) for tlf in dikt["commandFragments"])
209209
lto = dikt.get("lto")
210210
return cls(commandFragments, lto)
211211

@@ -222,7 +222,7 @@ class TargetSourceGroup(object):
222222

223223
def __init__(self, name: str, sources: List["TargetSource"]):
224224
self.name = name
225-
self.sources = []
225+
self.sources: list[TargetSource] = []
226226

227227
@classmethod
228228
def from_dict(cls, dikt: Dict, target_sources: List["TargetSource"]) -> "TargetSourceGroup":
@@ -283,7 +283,7 @@ def __repr__(self) -> str:
283283
class TargetCompileGroupPCH(object):
284284
__slots__ = ("header", "backtrace")
285285

286-
def __init__(self, header: Path, backtrace: BacktraceNode):
286+
def __init__(self, header: Path, backtrace: BacktraceNode | None):
287287
self.header = header
288288
self.backtrace = backtrace
289289

@@ -306,7 +306,7 @@ def __repr__(self) -> str:
306306
class TargetCompileGroupDefine(object):
307307
__slots__ = ("define", "backtrace")
308308

309-
def __init__(self, define: str, backtrace: BacktraceNode):
309+
def __init__(self, define: str, backtrace: BacktraceNode | None):
310310
self.define = define
311311
self.backtrace = backtrace
312312

@@ -370,7 +370,7 @@ class TargetDependency(object):
370370

371371
def __init__(self, id: str, backtrace: Optional[BacktraceNode]):
372372
self.id = id
373-
self.target = None # type: CodemodelTargetV2
373+
self.target: CodemodelTargetV2 | None = None
374374
self.backtrace = backtrace
375375

376376
def update_dependency(self, lut_id_target: Dict[str, "CodemodelTargetV2"]):
@@ -462,7 +462,7 @@ def update_dependencies(self, lut_id_target: Dict[str, "CodemodelTargetV2"]):
462462
dependency.update_dependency(lut_id_target)
463463

464464
@classmethod
465-
def from_dict(cls, dikt: Dict, reply_path: Path) -> "CodemodelTargetV2":
465+
def from_dict(cls, dikt: Dict) -> "CodemodelTargetV2":
466466
name = dikt["name"]
467467
id = dikt["id"]
468468
type = TargetType(dikt["type"])

cmake_file_api/py.typed

Whitespace-only changes.

requirements-dev.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
pytest
2+
mypy

0 commit comments

Comments
 (0)