Skip to content

Commit 62e7a42

Browse files
committed
Lint Fixes
1 parent 6a23ffe commit 62e7a42

File tree

5 files changed

+49
-32
lines changed

5 files changed

+49
-32
lines changed

cppython/core/resolution.py

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,21 @@ def resolve_pep621(
7676
return pep621_data
7777

7878

79+
def _resolve_absolute_path(path: Path, root_directory: Path) -> Path:
80+
"""Convert a path to absolute, using root_directory as base for relative paths.
81+
82+
Args:
83+
path: The path to resolve
84+
root_directory: The base directory for relative paths
85+
86+
Returns:
87+
The absolute path
88+
"""
89+
if path.is_absolute():
90+
return path
91+
return root_directory / path
92+
93+
7994
class PluginBuildData(CPPythonModel):
8095
"""Data needed to construct CoreData"""
8196

@@ -114,34 +129,20 @@ def resolve_cppython(
114129
"""
115130
root_directory = project_data.project_root.absolute()
116131

117-
# Add the base path to all relative paths
132+
# Resolve configuration path
118133
modified_configuration_path = local_configuration.configuration_path
119-
120-
# TODO: Grab configuration from the project, user, or system
121134
if modified_configuration_path is None:
122135
modified_configuration_path = root_directory / 'cppython.json'
136+
else:
137+
modified_configuration_path = _resolve_absolute_path(modified_configuration_path, root_directory)
123138

124-
if not modified_configuration_path.is_absolute():
125-
modified_configuration_path = root_directory / modified_configuration_path
126-
127-
modified_install_path = local_configuration.install_path
128-
129-
if not modified_install_path.is_absolute():
130-
modified_install_path = root_directory / modified_install_path
131-
132-
modified_tool_path = local_configuration.tool_path
133-
134-
if not modified_tool_path.is_absolute():
135-
modified_tool_path = root_directory / modified_tool_path
136-
137-
modified_build_path = local_configuration.build_path
138-
139-
if not modified_build_path.is_absolute():
140-
modified_build_path = root_directory / modified_build_path
139+
# Resolve other paths
140+
modified_install_path = _resolve_absolute_path(local_configuration.install_path, root_directory)
141+
modified_tool_path = _resolve_absolute_path(local_configuration.tool_path, root_directory)
142+
modified_build_path = _resolve_absolute_path(local_configuration.build_path, root_directory)
141143

142144
modified_provider_name = plugin_build_data.provider_name
143145
modified_generator_name = plugin_build_data.generator_name
144-
145146
modified_scm_name = plugin_build_data.scm_name
146147

147148
# Extract provider and generator configuration data

cppython/data.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
from dataclasses import dataclass
44
from logging import Logger
55

6+
from packaging.requirements import Requirement
7+
68
from cppython.core.plugin_schema.generator import Generator
79
from cppython.core.plugin_schema.provider import Provider
810
from cppython.core.plugin_schema.scm import SCM
@@ -71,8 +73,6 @@ def get_active_dependencies(self) -> list:
7173
Returns:
7274
Combined list of Requirement objects from base and active groups
7375
"""
74-
from packaging.requirements import Requirement
75-
7676
dependencies: list[Requirement] = list(self._core_data.cppython_data.dependencies)
7777

7878
if self._active_groups:

cppython/plugins/vcpkg/plugin.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,12 @@ async def download_tooling(cls, directory: Path) -> None:
231231

232232
cls._update_provider(directory)
233233

234-
def install(self) -> None:
235-
"""Called when dependencies need to be installed from a lock file."""
234+
def install(self, groups: list[str] | None = None) -> None:
235+
"""Called when dependencies need to be installed from a lock file.
236+
237+
Args:
238+
groups: Optional list of dependency group names to install (currently not used by vcpkg)
239+
"""
236240
manifest_directory = self.core_data.project_data.project_root
237241
manifest = generate_manifest(self.core_data, self.data)
238242

@@ -257,8 +261,12 @@ def install(self) -> None:
257261
except subprocess.CalledProcessError as e:
258262
self._handle_subprocess_error(logger, 'install project dependencies', e, ProviderInstallationError)
259263

260-
def update(self) -> None:
261-
"""Called when dependencies need to be updated and written to the lock file."""
264+
def update(self, groups: list[str] | None = None) -> None:
265+
"""Called when dependencies need to be updated and written to the lock file.
266+
267+
Args:
268+
groups: Optional list of dependency group names to update (currently not used by vcpkg)
269+
"""
262270
manifest_directory = self.core_data.project_data.project_root
263271

264272
manifest = generate_manifest(self.core_data, self.data)

cppython/test/mock/provider.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,20 @@ async def download_tooling(cls, directory: DirectoryPath) -> None:
8383
"""Downloads the provider tooling"""
8484
cls.downloaded = directory
8585

86-
def install(self) -> None:
87-
"""Installs the provider"""
86+
def install(self, groups: list[str] | None = None) -> None:
87+
"""Installs the provider
88+
89+
Args:
90+
groups: Optional list of dependency group names to install
91+
"""
8892
pass
8993

90-
def update(self) -> None:
91-
"""Updates the provider"""
94+
def update(self, groups: list[str] | None = None) -> None:
95+
"""Updates the provider
96+
97+
Args:
98+
groups: Optional list of dependency group names to update
99+
"""
92100
pass
93101

94102
def publish(self) -> None:

tests/fixtures/conan.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def clean_conan_cache(tmp_path: Path, monkeypatch: pytest.MonkeyPatch):
5151
if user_profiles.exists():
5252
test_profiles = conan_home / 'profiles'
5353
test_profiles.mkdir(parents=True, exist_ok=True)
54-
54+
5555
for profile_file in ('default', 'default_build'):
5656
if (src := user_profiles / profile_file).exists():
5757
src.copy(test_profiles / profile_file)

0 commit comments

Comments
 (0)