Skip to content

Commit f899efd

Browse files
Merge branch 'main' into tests
Resolve conflicts and run new versions of linters.
2 parents e4d8563 + 3241a11 commit f899efd

File tree

17 files changed

+120
-33
lines changed

17 files changed

+120
-33
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ repos:
5555

5656
# Lint python code with ruff (also sorts imports)
5757
- repo: https://github.com/charliermarsh/ruff-pre-commit
58-
rev: "5bd2636577fce68326b4fa0bea1769f02d7025bf" # frozen: v0.0.272
58+
rev: "bbaf495f2dc6ce2853c91dc0b2c75d3b8249c15c" # frozen: v0.1.15
5959
hooks:
6060
- id: ruff
6161
args: [--fix, --exit-non-zero-on-fix]

docs/poly.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
GitRef("dev", "", "", GitRefType.BRANCH, datetime.fromtimestamp(4)),
3636
GitRef("some-feature", "", "", GitRefType.BRANCH, datetime.fromtimestamp(5)),
3737
],
38-
"current": GitRef("local", "", "", GitRefType.BRANCH, datetime.fromtimestamp(6)),
38+
"current": GitRef("local", "", "", GitRefType.TAG, datetime.fromtimestamp(6)),
3939
}
4040
MOCK = False
4141

docs/sphinx/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ def linkcode_resolve(domain, info):
166166
.. seealso::
167167
168168
https://www.sphinx-doc.org/en/master/usage/extensions/linkcode.html#confval-linkcode_resolve
169+
169170
"""
170171
if domain != "py":
171172
return None

poetry.lock

Lines changed: 20 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,9 @@ jinja = ["jinja2"]
3737
sphinx-polyversion = "sphinx_polyversion.main:main"
3838

3939
[tool.poetry.group.lint.dependencies]
40-
mypy = "^1.3.0"
41-
ruff = "^0.0.272"
42-
black = "^23.3.0"
43-
40+
mypy = "^1.7.1"
41+
ruff = "^0.1.6"
42+
black = "^23.11.0"
4443

4544
[tool.poetry.group.test.dependencies]
4645
pytest = "^7.4.4"

sphinx_polyversion/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
logger: Logger
77
The root logger used by this package.
88
9+
910
"""
1011
from logging import DEBUG, NullHandler, getLogger
1112

sphinx_polyversion/api.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ def load(namespace: dict[str, Any] | None = None) -> Any:
3939
------
4040
LoadError
4141
The environment variable isn't set.
42+
4243
"""
4344
namespace = namespace or {}
4445

@@ -72,6 +73,7 @@ def apply_overrides(namespace: dict[str, Any]) -> dict[str, Any]:
7273
-------
7374
dict[str, Any]
7475
The values that were applied to the namespace.
76+
7577
"""
7678
args = get_parser(expect_config=False).parse_args()
7779
overrides: dict[str, Any] = args.override

sphinx_polyversion/builder.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,6 @@ async def build(self, environment: ENV, output_dir: Path, data: JSONable) -> R:
4343
Any
4444
Arbitrary data that results from building.
4545
This data can be used by custom :class:`Driver` implementations.
46+
4647
"""
4748
...

sphinx_polyversion/driver.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ class Driver(Generic[RT, ENV], metaclass=ABCMeta):
7474
-------
7575
run()
7676
Build all revisions.
77+
7778
"""
7879

7980
#: The version provider used by the driver e.g. to determine build targets.
@@ -103,6 +104,7 @@ def __init__(
103104
The directory where to place the built docs.
104105
mock : MockData[RT] | None | Literal[False], optional
105106
Only build from local files and mock building all docs using the data provided.
107+
106108
"""
107109
self.root = root
108110
self.output_dir = output_dir
@@ -123,6 +125,7 @@ def name_for_rev(self, rev: RT) -> str:
123125
-------
124126
str
125127
The name
128+
126129
"""
127130

128131
@abstractmethod
@@ -136,6 +139,7 @@ async def init_vcs(self) -> VersionProvider[RT]:
136139
Returns
137140
-------
138141
VersionProvider
142+
139143
"""
140144

141145
@abstractmethod
@@ -154,6 +158,7 @@ async def init_builder(self, rev: RT) -> Builder[ENV, Any]:
154158
Returns
155159
-------
156160
Builder
161+
157162
"""
158163

159164
@abstractmethod
@@ -174,6 +179,7 @@ async def init_environment(self, path: Path, rev: RT) -> ENV:
174179
Returns
175180
-------
176181
Environment
182+
177183
"""
178184

179185
@abstractmethod
@@ -192,6 +198,7 @@ async def init_data(self, rev: RT, env: ENV) -> JSONable:
192198
-------
193199
JSONable
194200
The metadata to pass to the builder.
201+
195202
"""
196203

197204
@abstractmethod
@@ -212,6 +219,7 @@ def tmp_dir(self, rev: RT) -> AsyncContextManager[Path]:
212219
-------
213220
AsyncContextManager[Path]
214221
A context manager creating and cleaning up the temp dir.
222+
215223
"""
216224

217225
@abstractmethod
@@ -227,6 +235,7 @@ def build_failed(self, rev: RT, exc_info: EXC_INFO) -> None:
227235
The revision that failed to build.
228236
exc_info : EXC_INFO
229237
The exception raised by the build steps.
238+
230239
"""
231240

232241
def build_succeeded(self, rev: RT, data: Any) -> None:
@@ -242,6 +251,7 @@ def build_succeeded(self, rev: RT, data: Any) -> None:
242251
The revision that was build.
243252
data : Any
244253
The data returned by the builder.
254+
245255
"""
246256
self.builds.append(rev)
247257

@@ -257,6 +267,7 @@ async def build_revision(self, rev: RT) -> None:
257267
----------
258268
rev : Any
259269
The revision to build.
270+
260271
"""
261272
builder = await self.init_builder(rev)
262273

@@ -303,6 +314,7 @@ async def build_local(self) -> None:
303314
------
304315
ValueError
305316
`self.mock` isn't set.
317+
306318
"""
307319
if not self.mock:
308320
raise ValueError("Missing mock data.")
@@ -407,6 +419,7 @@ class DefaultDriver(Driver[JRT, ENV], Generic[JRT, ENV, S]):
407419
The source directory for root level templates.
408420
mock : MockData[RT] | None | Literal[False], optional
409421
Only build from local files and mock building all docs using the data provided.
422+
410423
"""
411424

412425
def __init__(
@@ -461,6 +474,7 @@ def __init__(
461474
The source directory for root level templates.
462475
mock : MockData[RT] | None | Literal[False], optional
463476
Only build from local files and mock building all docs using the data provided.
477+
464478
"""
465479
super().__init__(Path(root), Path(output_dir), mock=mock)
466480
self.static_dir = Path(static_dir) if static_dir is not None else static_dir
@@ -494,6 +508,7 @@ def name_for_rev(self, rev: JRT) -> str:
494508
-------
495509
str
496510
The name
511+
497512
"""
498513
return self.namer(rev) if self.namer else self.vcs.name(rev)
499514

@@ -516,6 +531,7 @@ async def init_builder(self, rev: JRT) -> Builder[ENV, Any]:
516531
Returns
517532
-------
518533
Builder
534+
519535
"""
520536
if isinstance(self.builder, Mapping):
521537
r = self.selector(rev, self.builder.keys()) # type: ignore[misc]
@@ -541,6 +557,7 @@ async def init_environment(self, path: Path, rev: JRT) -> ENV:
541557
Returns
542558
-------
543559
Environment
560+
544561
"""
545562
if isinstance(self.env_factory, Mapping):
546563
r = self.selector(rev, self.env_factory.keys()) # type: ignore[misc]
@@ -573,6 +590,7 @@ async def init_data(self, rev: JRT, env: ENV) -> JSONable:
573590
-------
574591
JSONable
575592
The metadata to pass to the builder.
593+
576594
"""
577595
if not self.data_factory:
578596
return {"revisions": tuple(self.targets), "current": rev}
@@ -603,6 +621,7 @@ async def tmp_dir(self, rev: JRT) -> AsyncGenerator[Path, None]:
603621
-------
604622
AsyncContextManager[Path]
605623
A context manager creating and cleaning up the temp dir.
624+
606625
"""
607626
with tempfile.TemporaryDirectory() as tmp:
608627
yield Path(tmp)
@@ -619,6 +638,7 @@ def build_failed(self, rev: JRT, exc_info: EXC_INFO) -> None:
619638
The revision that failed to build.
620639
exc_info : EXC_INFO
621640
The exception raised by the build steps.
641+
622642
"""
623643
logger.error("Building %s failed", self.name_for_rev(rev), exc_info=exc_info)
624644

sphinx_polyversion/environment.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class Environment:
4141
-------
4242
run(*cmd: str, decode: bool = True, **kwargs: Any)
4343
Run a OS process in the environment.
44+
4445
"""
4546

4647
path: Path
@@ -55,6 +56,7 @@ def __init__(self, path: Path, name: str):
5556
The location of the current revision.
5657
name : str
5758
The name of the environment (usually the name of the current revision).
59+
5860
"""
5961
self.path = path.resolve()
6062
self.logger = ContextAdapter(getLogger(__name__), {"context": name})
@@ -84,6 +86,7 @@ async def run(
8486
The error output of the command
8587
returncode : int | None
8688
The returncode of the command
89+
8790
"""
8891
process = await asyncio.create_subprocess_exec(*cmd, **kwargs)
8992
out, err = await process.communicate()
@@ -111,6 +114,7 @@ def factory(cls: Type[ENV], **kwargs: Any) -> Callable[[Path, str], ENV]:
111114
-------
112115
Callable[[Path, str], ENV]
113116
The factory function.
117+
114118
"""
115119
return partial(cls, **kwargs)
116120

0 commit comments

Comments
 (0)