Skip to content

Commit 7d45683

Browse files
committed
Fix Type Errors
1 parent 90f87ca commit 7d45683

File tree

13 files changed

+39
-42
lines changed

13 files changed

+39
-42
lines changed

cppython/builder.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
from cppython.core.plugin_schema.generator import Generator
1010
from cppython.core.plugin_schema.provider import Provider
11-
from cppython.core.plugin_schema.scm import SCM
11+
from cppython.core.plugin_schema.scm import SCM, SupportedSCMFeatures
1212
from cppython.core.resolution import (
1313
PluginBuildData,
1414
PluginCPPythonData,
@@ -262,7 +262,7 @@ def select_scm(self, scm_plugins: list[type[SCM]], project_data: ProjectData) ->
262262
The selected SCM plugin type
263263
"""
264264
for scm_type in scm_plugins:
265-
if scm_type.features(project_data.project_root).repository:
265+
if cast(SupportedSCMFeatures, scm_type.features(project_data.project_root)).repository:
266266
return scm_type
267267

268268
self._logger.info('No SCM plugin was found that supports the given path')

cppython/core/plugin_schema/generator.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
DataPlugin,
1111
DataPluginGroupData,
1212
SupportedDataFeatures,
13+
SupportedFeatures,
1314
SyncData,
1415
)
1516

@@ -58,13 +59,13 @@ def __init__(
5859

5960
@staticmethod
6061
@abstractmethod
61-
def features(directory: DirectoryPath) -> SupportedGeneratorFeatures:
62+
def features(directory: DirectoryPath) -> SupportedFeatures:
6263
"""Broadcasts the shared features of the generator plugin to CPPython
6364
6465
Args:
6566
directory: The root directory where features are evaluated
6667
6768
Returns:
68-
The supported features
69+
The supported features - `SupportedGeneratorFeatures`. Cast to this type to help us avoid generic typing
6970
"""
7071
raise NotImplementedError

cppython/core/plugin_schema/provider.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
DataPlugin,
1212
DataPluginGroupData,
1313
SupportedDataFeatures,
14+
SupportedFeatures,
1415
SyncData,
1516
)
1617

@@ -67,14 +68,14 @@ def __init__(
6768

6869
@staticmethod
6970
@abstractmethod
70-
def features(directory: DirectoryPath) -> SupportedProviderFeatures:
71+
def features(directory: DirectoryPath) -> SupportedFeatures:
7172
"""Broadcasts the shared features of the Provider plugin to CPPython
7273
7374
Args:
7475
directory: The root directory where features are evaluated
7576
7677
Returns:
77-
The supported features
78+
The supported features - `SupportedProviderFeatures`. Cast to this type to help us avoid generic typing
7879
"""
7980
raise NotImplementedError
8081

cppython/core/plugin_schema/scm.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ def __init__(self, group_data: SCMPluginGroupData) -> None:
3131

3232
@staticmethod
3333
@abstractmethod
34-
def features(directory: DirectoryPath) -> SupportedSCMFeatures:
34+
def features(directory: DirectoryPath) -> SupportedFeatures:
3535
"""Broadcasts the shared features of the SCM plugin to CPPython
3636
3737
Args:
3838
directory: The root directory where features are evaluated
3939
4040
Returns:
41-
The supported features
41+
The supported features - `SupportedSCMFeatures`. Cast to this type to help us avoid generic typing
4242
"""
4343
raise NotImplementedError
4444

cppython/core/schema.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class ProjectConfiguration(CPPythonModel, extra='forbid'):
4444
bool, Field(description='Debug mode. Additional processing will happen to expose more debug information')
4545
] = False
4646

47-
@field_validator('verbosity')
47+
@field_validator('verbosity') # type: ignore
4848
@classmethod
4949
def min_max(cls, value: int) -> int:
5050
"""Validator that clamps the input value
@@ -118,7 +118,7 @@ class CPPythonData(CPPythonModel, extra='forbid'):
118118
scm_name: TypeName
119119
dependencies: list[Requirement]
120120

121-
@field_validator('configuration_path', 'install_path', 'tool_path', 'build_path')
121+
@field_validator('configuration_path', 'install_path', 'tool_path', 'build_path') # type: ignore
122122
@classmethod
123123
def validate_absolute_path(cls, value: Path) -> Path:
124124
"""Enforce the input is an absolute path
@@ -234,14 +234,14 @@ def __init__(
234234

235235
@staticmethod
236236
@abstractmethod
237-
def features(directory: DirectoryPath) -> SupportedDataFeatures:
237+
def features(directory: DirectoryPath) -> SupportedFeatures:
238238
"""Broadcasts the shared features of the data plugin to CPPython
239239
240240
Args:
241241
directory: The root directory where features are evaluated
242242
243243
Returns:
244-
The supported features
244+
The supported features - `SupportedDataFeatures`. Cast to this type to help us avoid generic typing
245245
"""
246246
raise NotImplementedError
247247

cppython/defaults.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
SCMPluginGroupData,
88
SupportedSCMFeatures,
99
)
10-
from cppython.core.schema import Information
10+
from cppython.core.schema import Information, SupportedFeatures
1111

1212

1313
class DefaultSCM(SCM):
@@ -18,11 +18,11 @@ def __init__(self, group_data: SCMPluginGroupData) -> None:
1818
self.group_data = group_data
1919

2020
@staticmethod
21-
def features(directory: DirectoryPath) -> SupportedSCMFeatures:
21+
def features(directory: DirectoryPath) -> SupportedFeatures:
2222
"""Broadcasts the shared features of the SCM plugin to CPPython
2323
2424
Returns:
25-
The supported features
25+
The supported features - `SupportedGeneratorFeatures`. Cast to this type to help us avoid generic typing
2626
"""
2727
return SupportedSCMFeatures(repository=True)
2828

cppython/plugins/cmake/plugin.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
GeneratorPluginGroupData,
99
SupportedGeneratorFeatures,
1010
)
11-
from cppython.core.schema import CorePluginData, Information, SyncData
11+
from cppython.core.schema import CorePluginData, Information, SupportedFeatures, SyncData
1212
from cppython.plugins.cmake.builder import Builder
1313
from cppython.plugins.cmake.resolution import resolve_cmake_data
1414
from cppython.plugins.cmake.schema import CMakeSyncData
@@ -28,11 +28,11 @@ def __init__(self, group_data: GeneratorPluginGroupData, core_data: CorePluginDa
2828
self._provider_directory = self._cppython_preset_directory / 'providers'
2929

3030
@staticmethod
31-
def features(directory: Path) -> SupportedGeneratorFeatures:
31+
def features(directory: Path) -> SupportedFeatures:
3232
"""Queries if CMake is supported
3333
3434
Returns:
35-
Supported?
35+
The supported features - `SupportedGeneratorFeatures`. Cast to this type to help us avoid generic typing
3636
"""
3737
return SupportedGeneratorFeatures()
3838

cppython/plugins/conan/plugin.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
from cppython.core.plugin_schema.generator import SyncConsumer
1414
from cppython.core.plugin_schema.provider import Provider, ProviderPluginGroupData, SupportedProviderFeatures
15-
from cppython.core.schema import CorePluginData, Information, SyncData
15+
from cppython.core.schema import CorePluginData, Information, SupportedFeatures, SyncData
1616
from cppython.plugins.cmake.plugin import CMakeGenerator
1717
from cppython.plugins.cmake.schema import CMakeSyncData
1818
from cppython.plugins.conan.builder import Builder
@@ -47,14 +47,14 @@ def _download_file(url: str, file: Path) -> None:
4747
out_file.write(content)
4848

4949
@staticmethod
50-
def features(directory: Path) -> SupportedProviderFeatures:
50+
def features(directory: Path) -> SupportedFeatures:
5151
"""Queries conan support
5252
5353
Args:
5454
directory: The directory to query
5555
5656
Returns:
57-
Supported features
57+
Supported features - `SupportedProviderFeatures`. Cast to this type to help us avoid generic typing
5858
"""
5959
return SupportedProviderFeatures()
6060

cppython/plugins/git/plugin.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
"""Git SCM Plugin
2-
3-
This module implements the Git SCM plugin for CPPython. It provides
4-
functionality for interacting with Git repositories, including feature
5-
detection, version extraction, and project description retrieval.
6-
"""
1+
"""Git SCM Plugin"""
72

83
from pathlib import Path
94

@@ -15,7 +10,7 @@
1510
SCMPluginGroupData,
1611
SupportedSCMFeatures,
1712
)
18-
from cppython.core.schema import Information
13+
from cppython.core.schema import Information, SupportedFeatures
1914

2015

2116
class GitSCM(SCM):
@@ -26,14 +21,14 @@ def __init__(self, group_data: SCMPluginGroupData) -> None:
2621
self.group_data = group_data
2722

2823
@staticmethod
29-
def features(directory: Path) -> SupportedSCMFeatures:
24+
def features(directory: Path) -> SupportedFeatures:
3025
"""Broadcasts the shared features of the SCM plugin to CPPython
3126
3227
Args:
3328
directory: The root directory where features are evaluated
3429
3530
Returns:
36-
The supported features
31+
The supported features - `SupportedSCMFeatures`. Cast to this type to help us avoid generic typing
3732
"""
3833
is_repository = True
3934
try:

cppython/plugins/vcpkg/plugin.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
ProviderPluginGroupData,
1313
SupportedProviderFeatures,
1414
)
15-
from cppython.core.schema import CorePluginData, Information, SyncData
15+
from cppython.core.schema import CorePluginData, Information, SupportedFeatures, SyncData
1616
from cppython.plugins.cmake.plugin import CMakeGenerator
1717
from cppython.plugins.cmake.schema import CMakeSyncData
1818
from cppython.plugins.vcpkg.resolution import generate_manifest, resolve_vcpkg_data
@@ -33,14 +33,14 @@ def __init__(
3333
self.data: VcpkgData = resolve_vcpkg_data(configuration_data, core_data)
3434

3535
@staticmethod
36-
def features(directory: Path) -> SupportedProviderFeatures:
36+
def features(directory: Path) -> SupportedFeatures:
3737
"""Queries vcpkg support
3838
3939
Args:
4040
directory: The directory to query
4141
4242
Returns:
43-
Supported features
43+
Supported features - `SupportedProviderFeatures`. Cast to this type to help us avoid generic typing
4444
"""
4545
return SupportedProviderFeatures()
4646

0 commit comments

Comments
 (0)