Skip to content

Commit bf576f9

Browse files
colyerdengShawnDen-coder
authored andcommitted
refactor: replace uvx with uv run in noxfile.py
1 parent 19b149b commit bf576f9

File tree

3 files changed

+35
-32
lines changed

3 files changed

+35
-32
lines changed

noxfile.py

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ def lint(session: nox.Session) -> None:
5858
install_with_uv(session, extras=["dev"])
5959

6060
# Run ruff checks
61-
session.run("uvx", "ruff", "check", ".")
62-
session.run("uvx", "ruff", "format", "--check", ".")
61+
session.run("uv", "run", "ruff", "check", ".")
62+
session.run("uv", "run", "ruff", "format", "--check", ".")
6363

6464

6565
@nox.session(python=PYTHON_VERSIONS[-1], reuse_venv=True)
@@ -77,10 +77,14 @@ def test(session: nox.Session) -> None:
7777

7878
# Run pytest with coverage
7979
session.run(
80-
"uvx",
80+
"uv",
81+
"run",
8182
"pytest",
83+
"--cov=repo_scaffold",
84+
"--cov-report=term-missing",
85+
"--cov-report=xml",
8286
"-v",
83-
"tests",
87+
"tests"
8488
)
8589

8690

@@ -96,22 +100,20 @@ def test_all(session: nox.Session) -> None:
96100
session: Nox session object for running commands
97101
"""
98102
# Install dependencies
103+
session.install("uv")
99104
install_with_uv(session, extras=["dev"])
100105

101-
# 确定是否是最新的 Python 版本
102-
is_latest_python = session.python == PYTHON_VERSIONS[-1]
103-
104-
# 构建测试命令
105-
test_args = ["-v", "tests"]
106-
if is_latest_python:
107-
test_args = [
108-
"--cov=repo_scaffold",
109-
"--cov-report=term-missing",
110-
"--cov-report=xml",
111-
] + test_args
112-
113106
# 运行测试
114-
session.run("uvx", "pytest", "-v", *test_args)
107+
session.run(
108+
"uv",
109+
"run",
110+
"pytest",
111+
"--cov=repo_scaffold",
112+
"--cov-report=term-missing",
113+
"--cov-report=xml",
114+
"-v",
115+
"tests"
116+
)
115117

116118

117119
@nox.session(reuse_venv=True)
@@ -192,8 +194,8 @@ def baseline(session: nox.Session) -> None:
192194
install_with_uv(session, extras=["dev"])
193195

194196
# 运行 ruff 并自动修复所有问题
195-
session.run("uvx","ruff", "check", ".", "--add-noqa")
196-
session.run("uvx","ruff", "format", ".")
197+
session.run("uv", "run", "ruff", "check", ".", "--add-noqa")
198+
session.run("uv", "run", "ruff", "format", ".")
197199

198200

199201
@nox.session(reuse_venv=True)
@@ -205,8 +207,9 @@ def docs(session: nox.Session) -> None:
205207
Args:
206208
session: Nox session object for running commands
207209
"""
210+
session.install("uv")
208211
install_with_uv(session, extras=["docs"])
209-
session.run("uvx","mkdocs", "build")
212+
session.run("uv", "run", "mkdocs", "build")
210213

211214

212215
@nox.session(reuse_venv=True)
@@ -218,5 +221,6 @@ def docs_serve(session: nox.Session) -> None:
218221
Args:
219222
session: Nox session object for running commands
220223
"""
224+
session.install("uv")
221225
install_with_uv(session, extras=["docs"])
222-
session.run("uvx","mkdocs", "serve")
226+
session.run("uv", "run", "mkdocs", "serve")

pyproject.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ docs = [
3232
"mkdocs-gen-files>=0.5.0",
3333
"mkdocs-literate-nav>=0.6.1",
3434
"pymdown-extensions>=10.7",
35+
"pymdown-extensions>=10.7",
3536
]
3637

3738
[project.scripts]
@@ -77,9 +78,6 @@ lines-after-imports = 2
7778
[tool.ruff.lint.pydocstyle]
7879
convention = "google"
7980

80-
[tool.pytest.ini_options]
81-
addopts = "--cov=repo_scaffold --cov-report=term-missing --cov-report=xml"
82-
testpaths = ["tests"]
8381

8482
[tool.commitizen]
8583
name = "cz_conventional_commits"

repo_scaffold/templates/template-python/{{cookiecutter.project_slug}}/noxfile.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ def lint(session: nox.Session) -> None:
6161
install_with_uv(session, extras=["dev"])
6262

6363
# Run ruff checks
64-
session.run("uvx", "ruff", "check", ".")
65-
session.run("uvx", "ruff", "format", "--check", ".")
64+
session.run("uv", "run", "ruff", "check", ".")
65+
session.run("uv", "run", "ruff", "format", "--check", ".")
6666

6767

6868
@nox.session(python=PYTHON_VERSIONS[-1], reuse_venv=True)
@@ -80,7 +80,8 @@ def test(session: nox.Session) -> None:
8080

8181
# Run pytest with coverage
8282
session.run(
83-
"uvx",
83+
"uv",
84+
"run",
8485
"pytest",
8586
"--cov={{cookiecutter.project_slug}}",
8687
"--cov-report=term-missing",
@@ -117,7 +118,7 @@ def test_all(session: nox.Session) -> None:
117118
] + test_args
118119

119120
# 运行测试
120-
session.run("uvx", "pytest", *test_args)
121+
session.run("uv", "run", "pytest", *test_args)
121122

122123

123124
@nox.session(reuse_venv=True)
@@ -198,8 +199,8 @@ def baseline(session: nox.Session) -> None:
198199
install_with_uv(session, extras=["dev"])
199200

200201
# 运行 ruff 并自动修复所有问题
201-
session.run("uvx", "ruff", "check", ".", "--add-noqa")
202-
session.run("uvx", "ruff", "format", ".")
202+
session.run("uv", "run", "ruff", "check", ".", "--add-noqa")
203+
session.run("uv", "run", "ruff", "format", ".")
203204

204205

205206
{% if cookiecutter.use_mkdocs == "yes" %}
@@ -213,7 +214,7 @@ def docs(session: nox.Session) -> None:
213214
session: Nox session object for running commands
214215
"""
215216
install_with_uv(session, extras=["docs"])
216-
session.run("uvx", "mkdocs", "build")
217+
session.run("uv", "run", "mkdocs", "build")
217218

218219

219220
@nox.session(reuse_venv=True)
@@ -226,5 +227,5 @@ def docs_serve(session: nox.Session) -> None:
226227
session: Nox session object for running commands
227228
"""
228229
install_with_uv(session, extras=["docs"])
229-
session.run("uvx", "mkdocs", "serve")
230+
session.run("uv", "run", "mkdocs", "serve")
230231
{% endif %}

0 commit comments

Comments
 (0)