Skip to content

Commit 90f87ca

Browse files
committed
Type Checking
1 parent b263317 commit 90f87ca

File tree

12 files changed

+33
-32
lines changed

12 files changed

+33
-32
lines changed

cppython/builder.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from importlib.metadata import entry_points
55
from inspect import getmodule
66
from logging import Logger
7-
from typing import Any
7+
from typing import Any, cast
88

99
from cppython.core.plugin_schema.generator import Generator
1010
from cppython.core.plugin_schema.provider import Provider
@@ -317,7 +317,7 @@ def create_scm(
317317
cppython_plugin_data = resolve_cppython_plugin(core_data.cppython_data, scm_type)
318318
scm_data = resolve_scm(core_data.project_data, cppython_plugin_data)
319319

320-
plugin = scm_type(scm_data)
320+
plugin = cast(SCM, scm_type(scm_data))
321321

322322
return plugin
323323

@@ -354,7 +354,7 @@ def create_generator(
354354
cppython_data=cppython_plugin_data,
355355
)
356356

357-
return generator_type(generator_data, core_plugin_data, generator_configuration)
357+
return cast(Generator, generator_type(generator_data, core_plugin_data, generator_configuration))
358358

359359
def create_provider(
360360
self,
@@ -389,7 +389,7 @@ def create_provider(
389389
cppython_data=cppython_plugin_data,
390390
)
391391

392-
return provider_type(provider_data, core_plugin_data, provider_configuration)
392+
return cast(Provider, provider_type(provider_data, core_plugin_data, provider_configuration))
393393

394394

395395
class Builder:

cppython/defaults.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def __init__(self, group_data: SCMPluginGroupData) -> None:
1818
self.group_data = group_data
1919

2020
@staticmethod
21-
def features(_: DirectoryPath) -> SupportedSCMFeatures:
21+
def features(directory: DirectoryPath) -> SupportedSCMFeatures:
2222
"""Broadcasts the shared features of the SCM plugin to CPPython
2323
2424
Returns:
@@ -36,7 +36,7 @@ def information() -> Information:
3636
return Information()
3737

3838
@staticmethod
39-
def version(_: DirectoryPath) -> str:
39+
def version(directory: DirectoryPath) -> str:
4040
"""Extracts the system's version metadata
4141
4242
Returns:

cppython/plugins/cmake/plugin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def __init__(self, group_data: GeneratorPluginGroupData, core_data: CorePluginDa
2828
self._provider_directory = self._cppython_preset_directory / 'providers'
2929

3030
@staticmethod
31-
def features(_: Path) -> SupportedGeneratorFeatures:
31+
def features(directory: Path) -> SupportedGeneratorFeatures:
3232
"""Queries if CMake is supported
3333
3434
Returns:

cppython/plugins/conan/builder.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,11 @@ def _update_requires(self, updated_node: cst.ClassDef) -> cst.ClassDef:
8383

8484
# Insert the new statement after the last attribute assignment
8585
if last_attribute is not None:
86-
new_body = list(updated_node.body.body)
86+
new_body = [item for item in updated_node.body.body]
8787
index = new_body.index(last_attribute)
8888
new_body.insert(index + 1, new_statement)
8989
else:
90-
new_body = [new_statement] + list(updated_node.body.body)
90+
new_body = [new_statement] + [item for item in updated_node.body.body]
9191
return updated_node.with_changes(body=updated_node.body.with_changes(body=new_body))
9292

9393
def _replace_requires(

cppython/plugins/git/plugin.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ def information() -> Information:
5252
"""
5353
return Information()
5454

55-
@staticmethod
56-
def version(_: Path) -> str:
55+
def version(self, directory: Path) -> str:
5756
"""Extracts the system's version metadata
5857
5958
Returns:

cppython/test/mock/generator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def __init__(
3232
self.configuration_data = MockGeneratorData(**configuration_data)
3333

3434
@staticmethod
35-
def features(_: DirectoryPath) -> SupportedGeneratorFeatures:
35+
def features(directory: DirectoryPath) -> SupportedGeneratorFeatures:
3636
"""Broadcasts the shared features of the generator plugin to CPPython
3737
3838
Returns:
@@ -58,5 +58,5 @@ def sync_types() -> list[type[SyncData]]:
5858
"""
5959
return [MockSyncData]
6060

61-
def sync(self, _: SyncData) -> None:
61+
def sync(self, sync_data: SyncData) -> None:
6262
"""Synchronizes generator files and state with the providers input"""

cppython/test/mock/provider.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def __init__(
3232
self.configuration_data = MockProviderData(**configuration_data)
3333

3434
@staticmethod
35-
def features(_: DirectoryPath) -> SupportedProviderFeatures:
35+
def features(directory: DirectoryPath) -> SupportedProviderFeatures:
3636
"""Broadcasts the shared features of the Provider plugin to CPPython
3737
3838
Returns:

cppython/test/mock/scm.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,12 @@ def __init__(self, group_data: SCMPluginGroupData) -> None:
1818
self.group_data = group_data
1919

2020
@staticmethod
21-
def features(_: DirectoryPath) -> SupportedSCMFeatures:
21+
def features(directory: DirectoryPath) -> SupportedSCMFeatures:
2222
"""Broadcasts the shared features of the SCM plugin to CPPython
2323
24+
Args:
25+
directory: The root directory where features are evaluated
26+
2427
Returns:
2528
The supported features
2629
"""
@@ -35,10 +38,12 @@ def information() -> Information:
3538
"""
3639
return Information()
3740

38-
@staticmethod
39-
def version(_: DirectoryPath) -> str:
41+
def version(self, directory: DirectoryPath) -> str:
4042
"""Extracts the system's version metadata
4143
44+
Args:
45+
directory: The input directory
46+
4247
Returns:
4348
A version
4449
"""

cppython/test/pytest/base_classes.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,8 @@ def fixture_plugin_group_data(
265265
Returns:
266266
The plugin configuration
267267
"""
268-
project_data.project_root = tmp_path_factory.mktemp('workspace-')
268+
workspace_path = tmp_path_factory.mktemp('workspace-')
269+
project_data = ProjectData(project_root=workspace_path, verbosity=project_data.verbosity)
269270
# Install path is already pinned to a temp directory to share downloaded resources
270271
cppython_plugin_data.build_path = project_data.project_root / 'build'
271272
cppython_plugin_data.tool_path = project_data.project_root / 'tool'
@@ -355,7 +356,8 @@ def fixture_plugin_group_data(
355356
Returns:
356357
The plugin configuration
357358
"""
358-
project_data.project_root = tmp_path_factory.mktemp('workspace-')
359+
workspace_path = tmp_path_factory.mktemp('workspace-')
360+
project_data = ProjectData(project_root=workspace_path, verbosity=project_data.verbosity)
359361
# Install path is already pinned to a temp directory to share downloaded resources
360362
cppython_plugin_data.build_path = project_data.project_root / 'build'
361363
cppython_plugin_data.tool_path = project_data.project_root / 'tool'
@@ -444,7 +446,8 @@ def fixture_plugin_group_data(
444446
Returns:
445447
The plugin configuration
446448
"""
447-
project_data.project_root = tmp_path_factory.mktemp('workspace-')
449+
workspace_path = tmp_path_factory.mktemp('workspace-')
450+
project_data = ProjectData(project_root=workspace_path, verbosity=project_data.verbosity)
448451
# Install path is already pinned to a temp directory to share downloaded resources
449452
cppython_plugin_data.build_path = project_data.project_root / 'build'
450453
cppython_plugin_data.tool_path = project_data.project_root / 'tool'

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ testpaths = ["tests"]
6464

6565
[tool.ruff]
6666
line-length = 120
67-
preview = true
6867

6968
[tool.ruff.lint]
7069
ignore = ["D206", "D300", "D415", "E111", "E114", "E117"]

0 commit comments

Comments
 (0)