Skip to content

Commit 6ad83cc

Browse files
committed
Run the linter
1 parent 8001976 commit 6ad83cc

File tree

6 files changed

+57
-44
lines changed

6 files changed

+57
-44
lines changed

src/jgo/cli/commands/search.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@
1010

1111
import rich_click as click
1212

13+
from ...parse.coordinate import Coordinate
1314
from ...util import is_info_enabled
1415
from ..console import console_print
16+
from ..rich.formatters import format_coordinate
1517

1618
if TYPE_CHECKING:
1719
from ..parser import ParsedArgs
@@ -217,10 +219,8 @@ def _display_results(results: list[dict]) -> None:
217219
version = result["latest_version"]
218220

219221
# Basic format: coordinate and latest version
220-
from ...parse.coordinate import Coordinate
221-
222222
coord = Coordinate(group_id, artifact_id, version)
223-
console_print(f"{i}. {coord.rich()}")
223+
console_print(f"{i}. {format_coordinate(coord)}")
224224

225225
if verbose:
226226
# Show additional details in verbose mode

src/jgo/cli/commands/versions.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import rich_click as click
99

1010
from ..console import console_print
11+
from ..rich.formatters import format_coordinate
1112

1213
if TYPE_CHECKING:
1314
from ..parser import ParsedArgs
@@ -71,14 +72,14 @@ def execute(args: ParsedArgs, config: dict) -> int:
7172
# Get available versions
7273
metadata = project.metadata
7374
if not metadata or not metadata.versions:
74-
console_print(f"No versions found for {coord.rich()}")
75+
console_print(f"No versions found for {format_coordinate(coord)}")
7576
return 0
7677

7778
# Use project's smart release/latest resolution
7879
release_version = project.release
7980
latest_version = project.latest
8081

81-
console_print(f"Available versions for {coord.rich()}:")
82+
console_print(f"Available versions for {format_coordinate(coord)}:")
8283
for version in metadata.versions:
8384
marker = ""
8485
if release_version and version == release_version:

src/jgo/cli/rich/formatters.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,53 @@
1111

1212
from rich.tree import Tree
1313

14+
from ...parse.coordinate import coord2str
1415
from .widgets import NoWrapTree
1516

1617
if TYPE_CHECKING:
1718
from ...maven.core import DependencyNode
19+
from ...parse.coordinate import Coordinate
20+
21+
22+
def format_coordinate(coord: Coordinate) -> str:
23+
"""
24+
Format a Maven coordinate with Rich markup for semantic coloring.
25+
26+
Uses Rich markup to colorize components based on their semantic meaning:
27+
- groupId: bold cyan
28+
- artifactId: bold
29+
- version: green
30+
- packaging: default color
31+
- classifier: default color
32+
- scope: dim
33+
- colons: dim
34+
35+
The markup is automatically stripped by Rich when --color=plain is used.
36+
37+
Args:
38+
coord: The Coordinate to format
39+
40+
Returns:
41+
Formatted string with Rich markup
42+
43+
Examples:
44+
>>> from jgo.parse.coordinate import Coordinate
45+
>>> coord = Coordinate("sc.fiji", "fiji", "2.17.0")
46+
>>> format_coordinate(coord)
47+
'[bold cyan]sc.fiji[/][dim]:[/][bold]fiji[/][dim]:[/][green]2.17.0[/]'
48+
"""
49+
return coord2str(
50+
coord.groupId,
51+
coord.artifactId,
52+
coord.version,
53+
coord.classifier,
54+
coord.packaging,
55+
coord.scope,
56+
coord.optional,
57+
coord.raw,
58+
coord.placement,
59+
rich=True,
60+
)
1861

1962

2063
def format_dependency_list(

src/jgo/parse/coordinate.py

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -76,42 +76,6 @@ def __str__(self) -> str:
7676
self.placement,
7777
)
7878

79-
def rich(self) -> str:
80-
"""
81-
Return Rich-formatted string representation with semantic colors.
82-
83-
Uses Rich markup to colorize components based on their semantic meaning:
84-
- groupId: bold cyan
85-
- artifactId: bold
86-
- version: green
87-
- packaging: default color
88-
- classifier: default color
89-
- scope: dim
90-
- colons: dim
91-
92-
The markup is automatically stripped by Rich when --color=plain is used.
93-
94-
Returns:
95-
Formatted string with Rich markup
96-
97-
Examples:
98-
>>> coord = Coordinate("sc.fiji", "fiji", "2.17.0")
99-
>>> coord.rich()
100-
'[bold cyan]sc.fiji[/][dim]:[/][bold]fiji[/][dim]:[/][green]2.17.0[/]'
101-
"""
102-
return coord2str(
103-
self.groupId,
104-
self.artifactId,
105-
self.version,
106-
self.classifier,
107-
self.packaging,
108-
self.scope,
109-
self.optional,
110-
self.raw,
111-
self.placement,
112-
rich=True,
113-
)
114-
11579
@classmethod
11680
def parse(cls, coordinate: "Coordinate" | str) -> "Coordinate":
11781
"""

tests/conftest.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
from pathlib import Path
66

77
import pytest
8+
from tests.fixtures.thicket import DEFAULT_SEED, generate_thicket
89

910
from jgo.util.maven import ensure_maven_available
10-
from tests.fixtures.thicket import DEFAULT_SEED, generate_thicket
1111

1212

1313
@pytest.fixture(scope="session")
@@ -61,7 +61,13 @@ def m2_repo(tmp_path_factory):
6161
# If cache is already populated, these will be quick no-ops
6262
for goal in ["dependency:list", "dependency:tree"]:
6363
subprocess.run(
64-
[maven_cmd, "-f", str(bootstrap_pom), f"-Dmaven.repo.local={cache_dir}", goal],
64+
[
65+
maven_cmd,
66+
"-f",
67+
str(bootstrap_pom),
68+
f"-Dmaven.repo.local={cache_dir}",
69+
goal,
70+
],
6571
check=True,
6672
capture_output=True,
6773
)

tests/test_resolution.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,6 @@ def mvn_resolver(maven_command):
201201
ids=lambda case: case.endpoint,
202202
)
203203
def test_resolution_modes(m2_repo, scenario, mvn_resolver):
204-
205204
python_resolver = PythonResolver()
206205
context = MavenContext(repo_cache=m2_repo, resolver=python_resolver)
207206
components = components_from_endpoint(context, scenario.endpoint)

0 commit comments

Comments
 (0)