Skip to content

Commit e151471

Browse files
committed
refactor: revert staticmethod change
1 parent cc53c30 commit e151471

File tree

2 files changed

+8
-36
lines changed

2 files changed

+8
-36
lines changed

hatch_nodejs_version/version_source.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ def path(self):
9494

9595
return self.__path
9696

97-
def node_version_to_python(self, version: str) -> str:
97+
@staticmethod
98+
def node_version_to_python(version: str) -> str:
9899
# NodeJS version strings are a near superset of Python version strings
99100
match = re.match(
100101
r"^\s*" + NODE_VERSION_PATTERN + r"\s*$",
@@ -117,7 +118,8 @@ def node_version_to_python(self, version: str) -> str:
117118

118119
return "".join(parts)
119120

120-
def python_version_to_node(self, version: str) -> str:
121+
@staticmethod
122+
def python_version_to_node(version: str) -> str:
121123
# NodeJS version strings are a near superset of Python version strings
122124
match = re.match(
123125
r"^\s*" + PYTHON_VERSION_PATTERN + r"\s*$",

tests/test_version_config.py

Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -36,24 +36,9 @@ class TestVersion:
3636
"1.4.5rc0.post1+bad_",
3737
],
3838
)
39-
def test_parse_python_incorrect(self, project, python_version):
40-
# Create a simple project
41-
(project / "pyproject.toml").write_text(
42-
"""
43-
[build-system]
44-
requires = ["hatchling", "hatch-vcs"]
45-
build-backend = "hatchling.build"
46-
[project]
47-
name = "my-app"
48-
dynamic = ["version"]
49-
[tool.hatch.version]
50-
source = "nodejs"
51-
"""
52-
)
53-
config = {}
54-
version_source = NodeJSVersionSource(project, config=config)
39+
def test_parse_python_incorrect(self, python_version):
5540
with pytest.raises(ValueError, match=".* did not match regex"):
56-
version_source.python_version_to_node(python_version)
41+
NodeJSVersionSource.python_version_to_node(python_version)
5742

5843
@pytest.mark.parametrize(
5944
"node_version",
@@ -66,24 +51,9 @@ def test_parse_python_incorrect(self, project, python_version):
6651
"1.4.5-rc0.post1+bad_",
6752
],
6853
)
69-
def test_parse_node_incorrect(self, project, node_version):
70-
# Create a simple project
71-
(project / "pyproject.toml").write_text(
72-
"""
73-
[build-system]
74-
requires = ["hatchling", "hatch-vcs"]
75-
build-backend = "hatchling.build"
76-
[project]
77-
name = "my-app"
78-
dynamic = ["version"]
79-
[tool.hatch.version]
80-
source = "nodejs"
81-
"""
82-
)
83-
config = {}
84-
version_source = NodeJSVersionSource(project, config=config)
54+
def test_parse_node_incorrect(self, node_version):
8555
with pytest.raises(ValueError, match=".* did not match regex"):
86-
version_source.node_version_to_python(node_version)
56+
NodeJSVersionSource.node_version_to_python(node_version)
8757

8858
@pytest.mark.parametrize(
8959
"node_version, python_version",

0 commit comments

Comments
 (0)