Skip to content

Commit 63d785c

Browse files
committed
Create full dependency group for type checking
1 parent f22e3b7 commit 63d785c

File tree

2 files changed

+48
-15
lines changed

2 files changed

+48
-15
lines changed

noxfile.py

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@
2424
"common-wheels": "tests/data/common_wheels",
2525
"protected-pip": "tools/protected_pip.py",
2626
}
27-
REQUIREMENTS = {
28-
"docs": "docs/requirements.txt",
29-
}
3027

3128
AUTHORS_FILE = "AUTHORS.txt"
3229
VERSION_FILE = "src/pip/__init__.py"
@@ -132,7 +129,7 @@ def test(session: nox.Session) -> None:
132129

133130
@nox.session
134131
def docs(session: nox.Session) -> None:
135-
session.install("-r", REQUIREMENTS["docs"])
132+
session.install("--group", "docs")
136133

137134
def get_sphinx_build_command(kind: str) -> list[str]:
138135
# Having the conf.py in the docs/html is weird but needed because we
@@ -161,7 +158,7 @@ def get_sphinx_build_command(kind: str) -> list[str]:
161158

162159
@nox.session(name="docs-live")
163160
def docs_live(session: nox.Session) -> None:
164-
session.install("-r", REQUIREMENTS["docs"], "sphinx-autobuild")
161+
session.install("--group", "docs", "sphinx-autobuild")
165162

166163
session.run(
167164
"sphinx-autobuild",
@@ -176,15 +173,12 @@ def docs_live(session: nox.Session) -> None:
176173

177174
@nox.session
178175
def typecheck(session: nox.Session) -> None:
179-
session.install(
180-
"mypy",
181-
"keyring",
182-
"nox",
183-
"pytest",
184-
"types-docutils",
185-
"types-setuptools",
186-
"types-freezegun",
187-
"types-pyyaml",
176+
# Install test and test-types dependency groups
177+
run_with_protected_pip(
178+
session,
179+
"install",
180+
"--group",
181+
"type-check",
188182
)
189183

190184
session.run(
@@ -290,7 +284,7 @@ def coverage(session: nox.Session) -> None:
290284
run_with_protected_pip(session, "install", ".")
291285

292286
# Install test dependencies
293-
run_with_protected_pip(session, "install", "-r", REQUIREMENTS["tests"])
287+
run_with_protected_pip(session, "install", "--group", "docs")
294288

295289
if not os.path.exists(".coverage-output"):
296290
os.mkdir(".coverage-output")

pyproject.toml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,45 @@ test-common-wheels = [
7878
"coverage >= 4.4",
7979
]
8080

81+
docs = [
82+
"sphinx ~= 7.0",
83+
# currently incompatible with sphinxcontrib-towncrier
84+
# https://github.com/sphinx-contrib/sphinxcontrib-towncrier/issues/92
85+
"towncrier < 24",
86+
"furo",
87+
"myst_parser",
88+
"sphinx-copybutton",
89+
"sphinx-inline-tabs",
90+
"sphinxcontrib-towncrier >= 0.2.0a0",
91+
"sphinx-issues"
92+
]
93+
94+
# Libraries that are not required for pip to run,
95+
# but are used in some optional features.
96+
all-optional = ["keyring"]
97+
98+
nox = ["nox"] # noxfile.py
99+
update-rtd-redirects = ["httpx", "rich"] # tools/update-rtd-redirects.py
100+
101+
type-check = [
102+
# Actual type checker:
103+
"mypy",
104+
105+
# Stub libraries that contain type hints as a separate package:
106+
"types-docutils", # via sphinx (test dependency)
107+
"types-requests", # vendored
108+
"types-urllib3", # vendored (can be removed when we upgrade to urllib3 >= 2.0)
109+
"types-setuptools", # test dependency and used in distutils_hack
110+
"types-six", # via python-dateutil via freezegun (test dependency)
111+
112+
# Everything else that could contain type hints:
113+
{include-group = "test"},
114+
{include-group = "docs"},
115+
{include-group = "nox"},
116+
{include-group = "all-optional"},
117+
{include-group = "update-rtd-redirects"},
118+
]
119+
81120
[tool.setuptools]
82121
package-dir = {"" = "src"}
83122
include-package-data = false

0 commit comments

Comments
 (0)