Skip to content

Commit 116a32d

Browse files
enabling mypyc
Signed-off-by: romintomasetti <[email protected]>
1 parent dd3ac84 commit 116a32d

14 files changed

Lines changed: 56 additions & 31 deletions

File tree

.github/workflows/ci.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,20 @@ jobs:
4545
python-version: "3.12"
4646
- run: pip install pylint
4747
- run: pylint --verbose --fail-under=10 --rcfile .pylintrc cmake_file_api
48+
49+
mypyc:
50+
runs-on: ubuntu-latest
51+
strategy:
52+
fail-fast: false
53+
matrix:
54+
py: ['3.10', '3.11', '3.12', '3.13', '3.14']
55+
steps:
56+
- uses: actions/checkout@v6
57+
- uses: actions/setup-python@v6
58+
with:
59+
python-version: ${{ matrix.py }}
60+
- run: pip install -r requirements-dev.txt
61+
- run: python setup.py bdist_wheel --dist-dir wheelhouse
62+
- run: pip install --no-deps --no-index --find-links=wheelhouse/ cmake_file_api
63+
- run: rm -rf cmake_file_api/
64+
- run: pytest --log-cli-level=info -vvv tests/

cmake_file_api/kinds/api.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from pathlib import Path
2-
from typing import Protocol
2+
from typing import ClassVar, Protocol
33

44
from .kind import ObjectKind
55
from .cache.api import CACHE_API
@@ -10,13 +10,13 @@
1010

1111

1212
class CMakeApiType(Protocol):
13-
KIND: ObjectKind
13+
KIND: ClassVar[ObjectKind]
1414

1515
@classmethod
1616
def from_path(cls, path: Path, reply_path: Path) -> "CMakeApiType":
1717
...
1818

19-
OBJECT_KINDS_API: dict[ObjectKind, dict[int, CMakeApiType]] = {
19+
OBJECT_KINDS_API: dict[ObjectKind, dict[int, type[CMakeApiType]]] = {
2020
ObjectKind.CACHE: CACHE_API,
2121
ObjectKind.CMAKEFILES: CMAKEFILES_API,
2222
ObjectKind.CONFIGURELOG: CONFIGURELOG_API,

cmake_file_api/kinds/cache/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
if typing.TYPE_CHECKING:
77
from ..api import CMakeApiType
88

9-
CACHE_API: dict[int, CMakeApiType] = {
9+
CACHE_API: dict[int, type[CMakeApiType]] = {
1010
2: CacheV2,
1111
}

cmake_file_api/kinds/cmakeFiles/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
if typing.TYPE_CHECKING:
77
from ..api import CMakeApiType
88

9-
CMAKEFILES_API: dict[int, CMakeApiType] = {
9+
CMAKEFILES_API: dict[int, type[CMakeApiType]] = {
1010
1: CMakeFilesV1,
1111
}

cmake_file_api/kinds/cmakeFiles/v1.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import json
22
from pathlib import Path
3-
from typing import Any, Optional
3+
from typing import Any, ClassVar, Optional
44

55
from cmake_file_api.kinds.common import CMakeSourceBuildPaths, VersionMajorMinor
66
from cmake_file_api.kinds.kind import ObjectKind
@@ -34,7 +34,7 @@ def __repr__(self) -> str:
3434

3535

3636
class CMakeFilesV1:
37-
KIND = ObjectKind.CMAKEFILES
37+
KIND: ClassVar = ObjectKind.CMAKEFILES
3838

3939
__slots__ = ("version", "paths", "inputs")
4040

cmake_file_api/kinds/codemodel/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
if typing.TYPE_CHECKING:
88
from ..api import CMakeApiType
99

10-
CODEMODEL_API: dict[int, CMakeApiType] = {
10+
CODEMODEL_API: dict[int, type[CMakeApiType]] = {
1111
2: CodemodelV2,
1212
}

cmake_file_api/kinds/codemodel/v2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def __repr__(self) -> str:
4343
class CMakeDirectory:
4444
__slots__ = ("source", "build", "parentDirectory", "childDirectories", "project", "targets", "minimumCMakeVersion", "hasInstallRule")
4545

46-
def __init__(self, source: Path, build: Path, minimumCMakeVersion: Optional[str], hasInstallRule: bool):
46+
def __init__(self, source: Path, build: Path, minimumCMakeVersion: Optional[str], hasInstallRule: bool) -> None:
4747
self.source = source
4848
self.build = build
4949
self.parentDirectory: Optional[CMakeDirectory] = None

cmake_file_api/kinds/common.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,16 @@
1+
import dataclasses
12
from pathlib import Path
23
from typing import Any
34

45

6+
@dataclasses.dataclass(frozen=True, slots=True)
57
class VersionMajorMinor:
6-
__slots__ = ("major", "minor")
7-
8-
def __init__(self, major: int, minor: int):
9-
self.major = major
10-
self.minor = minor
8+
major: int
9+
minor: int
1110

1211
@classmethod
1312
def from_dict(cls, d: dict[str, int]) -> "VersionMajorMinor":
14-
return cls(int(d["major"]), int(d["minor"]))
15-
16-
def __repr__(self) -> str:
17-
return "Version({}.{})".format(
18-
self.major,
19-
self.minor,
20-
)
13+
return cls(d["major"], d["minor"])
2114

2215

2316
class CMakeSourceBuildPaths:

cmake_file_api/kinds/configureLog/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
if typing.TYPE_CHECKING:
77
from ..api import CMakeApiType
88

9-
CONFIGURELOG_API: dict[int, CMakeApiType] = {
9+
CONFIGURELOG_API: dict[int, type[CMakeApiType]] = {
1010
1: ConfigureLogV1,
1111
}

cmake_file_api/kinds/toolchains/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
if typing.TYPE_CHECKING:
77
from ..api import CMakeApiType
88

9-
TOOLCHAINS_API: dict[int, CMakeApiType] = {
9+
TOOLCHAINS_API: dict[int, type[CMakeApiType]] = {
1010
1: ToolchainsV1,
1111
}

0 commit comments

Comments
 (0)