Skip to content

Commit 5035fde

Browse files
committed
Update pre-commits hooks and prune unnecessary ones
I can always re-add them later but for now the removed ones don't really apply.
1 parent 3bd33e4 commit 5035fde

File tree

3 files changed

+26
-24
lines changed

3 files changed

+26
-24
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ exclude: |
77
88
repos:
99
- repo: https://github.com/pre-commit/pre-commit-hooks
10-
rev: "2c9f875913ee60ca25ce70243dc24d5b6415598c" # frozen: v4.6.0
10+
rev: "cef0300fd0fc4d2a87a85fa2093c6b283ea36f4b" # frozen: v5.0.0
1111
hooks:
1212
- id: check-added-large-files
1313
- id: check-ast
@@ -27,25 +27,13 @@ repos:
2727
- id: requirements-txt-fixer
2828
- id: trailing-whitespace
2929

30-
- repo: https://github.com/pre-commit/pygrep-hooks
31-
rev: "3a6eb0fadf60b3cccfd80bad9dbb6fae7e47b316" # frozen: v1.10.0
32-
hooks:
33-
- id: rst-backticks
34-
- id: rst-directive-colons
35-
- id: rst-inline-touching-normal
36-
3730
- repo: https://github.com/psf/black
38-
rev: "3702ba224ecffbcec30af640c149f231d90aebdb" # frozen: 24.4.2
31+
rev: "1b2427a2b785cc4aac97c19bb4b9a0de063f9547" # frozen: 24.10.0
3932
hooks:
4033
- id: black
4134

42-
- repo: https://github.com/adamchainz/blacken-docs
43-
rev: "960ead214cd1184149d366c6d27ca6c369ce46b6" # frozen: 1.16.0
44-
hooks:
45-
- id: blacken-docs
46-
4735
- repo: https://github.com/astral-sh/ruff-pre-commit
48-
rev: "596470fba20d04adc68ec7903ff69a12e5e1a8d3" # frozen: v0.4.2
36+
rev: "75b98813cfb7e663870a28c74366a1e99d7bfe79" # frozen: v0.6.9
4937
hooks:
5038
- id: ruff
5139
args: ["--fix", "--show-fixes", "--exit-non-zero-on-fix"]

src/docstub/_analysis.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,33 @@
1818
logger = logging.getLogger(__name__)
1919

2020

21-
def _shared_leading_path(*paths):
22-
"""Identify the common leading parts between import paths.
21+
def _shared_leading_qualname(*qualnames):
22+
"""Identify the common leading parts between fully qualified names.
2323
2424
Parameters
2525
----------
26-
*paths : tuple[str]
26+
*qualnames : tuple[str]
2727
2828
Returns
2929
-------
3030
shared : str
31+
The names, still split by ".", that are common to the start of all given
32+
`qualnames`. Empty string if nothing is common.
33+
34+
Examples
35+
--------
36+
>>> _shared_leading_qualname("foo.bar", "foo.baz")
37+
'foo'
38+
>>> _shared_leading_qualname("foo.bar", "faa.baz")
39+
''
3140
"""
32-
if len(paths) < 2:
41+
if len(qualnames) < 2:
3342
raise ValueError("need more than two paths")
34-
splits = (p.split(".") for p in paths)
43+
splits = (p.split(".") for p in qualnames)
3544
shared = []
36-
for paths in zip(*splits, strict=False):
37-
if all(paths[0] == p for p in paths):
38-
shared.append(paths[0])
45+
for names in zip(*splits, strict=False):
46+
if all(names[0] == p for p in names):
47+
shared.append(names[0])
3948
else:
4049
break
4150
return ".".join(shared)
@@ -147,7 +156,7 @@ def format_import(self, relative_to=None):
147156
import_path = self.import_path
148157
if import_path:
149158
if relative_to:
150-
shared = _shared_leading_path(relative_to, import_path)
159+
shared = _shared_leading_qualname(relative_to, import_path)
151160
if shared == import_path:
152161
import_path = "."
153162
else:

src/docstub/_version.pyi

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
VERSION_TUPLE = tuple[int | str, ...]
2+
3+
version: str
4+
__version__: str
5+
__version_tuple__: VERSION_TUPLE

0 commit comments

Comments
 (0)