Skip to content

Commit ae8867f

Browse files
authored
Add (some) suggestions from repo-review (#81)
* Update pre-commit-hooks, use ruff instead of black and remove unecessary ones. * Update pytest config with suggestions from repo-review also use a consistent indent. * Enable quarterly github-action updates with dependabot * Update mypy config with recommendations from repo-review * Update formatting in example package too * Disable mypy's warn_unreachable due to false positive
1 parent ab90c82 commit ae8867f

File tree

10 files changed

+88
-75
lines changed

10 files changed

+88
-75
lines changed

.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: 2
2+
updates:
3+
# Maintain dependencies for GitHub Actions
4+
- package-ecosystem: "github-actions"
5+
directory: "/"
6+
schedule:
7+
interval: "quarterly"
8+
groups:
9+
actions:
10+
patterns:
11+
- "*"

.pre-commit-config.yaml

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,33 +7,28 @@ exclude: |
77
88
repos:
99
- repo: https://github.com/pre-commit/pre-commit-hooks
10-
rev: "cef0300fd0fc4d2a87a85fa2093c6b283ea36f4b" # frozen: v5.0.0
10+
rev: "3e8a8703264a2f4a69428a0aa4dcb512790b2c8c" # frozen: v6.0.0
1111
hooks:
1212
- id: check-added-large-files
1313
- id: check-ast
14-
- id: check-builtin-literals
1514
- id: check-case-conflict
1615
- id: check-merge-conflict
1716
- id: check-symlinks
18-
- id: check-yaml
19-
args: [--allow-multiple-documents]
2017
- id: check-json
2118
- id: check-toml
19+
- id: check-yaml
20+
args: [--allow-multiple-documents]
2221
- id: debug-statements
23-
- id: end-of-file-fixer
22+
- id: detect-private-key
2423
- id: mixed-line-ending
2524
- id: name-tests-test
2625
args: ["--pytest-test-first"]
27-
- id: requirements-txt-fixer
2826
- id: trailing-whitespace
29-
30-
- repo: https://github.com/psf/black
31-
rev: "1b2427a2b785cc4aac97c19bb4b9a0de063f9547" # frozen: 24.10.0
32-
hooks:
33-
- id: black
27+
args: [--markdown-linebreak-ext=md]
3428

3529
- repo: https://github.com/astral-sh/ruff-pre-commit
36-
rev: "75b98813cfb7e663870a28c74366a1e99d7bfe79" # frozen: v0.6.9
30+
rev: "0acff885bcb16381b67930fefb91e460202f172c" # frozen: v0.12.10
3731
hooks:
38-
- id: ruff
32+
- id: ruff-check
3933
args: ["--fix", "--show-fixes", "--exit-non-zero-on-fix"]
34+
- id: ruff-format

examples/example_pkg-stubs/_basic.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ from . import AnotherType, CustomException
1313
logger: logging.Logger
1414

1515
__all__ = [
16-
"func_empty",
1716
"ExampleClass",
17+
"func_empty",
1818
]
1919

2020
def func_empty(a1: Incomplete, a2: Incomplete, a3) -> None: ...

examples/example_pkg/_basic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919

2020

2121
__all__ = [
22-
"func_empty",
2322
"ExampleClass",
23+
"func_empty",
2424
]
2525

2626

pyproject.toml

Lines changed: 63 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
55
[project]
66
name = "docstub"
77
maintainers = [
8-
{name = "Lars Grüter"},
8+
{name = "Lars Grüter"},
99
]
1010
description = "Generate Python stub files from docstrings"
1111
readme = "README.md"
@@ -17,39 +17,39 @@ license-files = ["LICENSE.txt"]
1717
requires-python = ">=3.12"
1818
keywords = ["typing", "stub files", "docstings", "numpydoc"]
1919
classifiers = [
20-
"Development Status :: 3 - Alpha",
21-
"Environment :: Console",
22-
"Intended Audience :: Developers",
23-
"Intended Audience :: Science/Research",
24-
"Operating System :: OS Independent",
25-
"Programming Language :: Python",
26-
"Programming Language :: Python :: 3",
27-
"Programming Language :: Python :: 3 :: Only",
28-
"Programming Language :: Python :: 3.12",
29-
"Programming Language :: Python :: 3.13",
30-
"Topic :: Software Development :: Code Generators",
31-
"Topic :: Scientific/Engineering",
20+
"Development Status :: 3 - Alpha",
21+
"Environment :: Console",
22+
"Intended Audience :: Developers",
23+
"Intended Audience :: Science/Research",
24+
"Operating System :: OS Independent",
25+
"Programming Language :: Python",
26+
"Programming Language :: Python :: 3",
27+
"Programming Language :: Python :: 3 :: Only",
28+
"Programming Language :: Python :: 3.12",
29+
"Programming Language :: Python :: 3.13",
30+
"Topic :: Software Development :: Code Generators",
31+
"Topic :: Scientific/Engineering",
3232
]
3333
dynamic = ["version"]
3434
dependencies = [
35-
"numpydoc >=1.7.0",
36-
"click >=8.1.7",
37-
"libcst >=1.3.1",
38-
"lark >=1.1.9",
39-
"black >=24.4.2",
40-
"isort >=5.13.2",
35+
"numpydoc >=1.7.0",
36+
"click >=8.1.7",
37+
"libcst >=1.3.1",
38+
"lark >=1.1.9",
39+
"black >=24.4.2",
40+
"isort >=5.13.2",
4141
]
4242

4343
[project.optional-dependencies]
4444
dev = [
45-
"pre-commit >=3.7",
46-
"ipython",
45+
"pre-commit >=4.3.0",
46+
"ipython",
4747
]
4848
test = [
49-
"pytest >=5.0.0",
50-
"pytest-cov >= 5.0.0",
51-
"mypy>=1.16.0",
52-
"basedpyright",
49+
"pytest >=8.4.1",
50+
"pytest-cov >= 5.0.0",
51+
"mypy >=1.17.0",
52+
"basedpyright >=1.31",
5353
]
5454

5555
[project.urls]
@@ -68,42 +68,49 @@ src = ["src", "tests"]
6868

6969
[tool.ruff.lint]
7070
extend-select = [
71-
"B", # flake8-bugbear
72-
"I", # isort
73-
"C4", # flake8-comprehensions
74-
"ICN", # flake8-import-conventions
75-
"G", # flake8-logging-format
76-
"PGH", # pygrep-hooks
77-
"PIE", # flake8-pie
78-
"PL", # pylint
79-
"PT", # flake8-pytest-style
80-
"PTH", # flake8-use-pathlib
81-
"RET", # flake8-return
82-
"RUF", # Ruff-specific
83-
"SIM", # flake8-simplify
84-
"T20", # flake8-print
85-
"UP", # pyupgrade
86-
"YTT", # flake8-2020
87-
"EXE", # flake8-executable
88-
# "PYI", # flake8-pyi
71+
"B", # flake8-bugbear
72+
"I", # isort
73+
"C4", # flake8-comprehensions
74+
"ICN", # flake8-import-conventions
75+
"G", # flake8-logging-format
76+
"PGH", # pygrep-hooks
77+
"PIE", # flake8-pie
78+
"PL", # pylint
79+
"PT", # flake8-pytest-style
80+
"PTH", # flake8-use-pathlib
81+
"RET", # flake8-return
82+
"RUF", # Ruff-specific
83+
"SIM", # flake8-simplify
84+
"T20", # flake8-print
85+
"UP", # pyupgrade
86+
"YTT", # flake8-2020
87+
"EXE", # flake8-executable
88+
# "PYI", # flake8-pyi
8989
]
9090
ignore = [
91-
"PLR09", # Too many <...>
92-
"PLR2004", # Magic value used in comparison
93-
"ISC001", # Conflicts with formatter
94-
"RET504", # Assignment before `return` statement facilitates debugging
95-
"PTH123", # Using builtin open() instead of Path.open() is fine
96-
"SIM108", # Terniary operator is always more readable
97-
"SIM103", # Don't recommend returning the condition directly
91+
"PLR09", # Too many <...>
92+
"PLR2004", # Magic value used in comparison
93+
"ISC001", # Conflicts with formatter
94+
"RET504", # Assignment before `return` statement facilitates debugging
95+
"PTH123", # Using builtin open() instead of Path.open() is fine
96+
"SIM108", # Terniary operator is always more readable
97+
"SIM103", # Don't recommend returning the condition directly
9898
]
9999

100100

101101
[tool.pytest.ini_options]
102-
addopts = "--doctest-modules"
103-
testpaths = [
104-
"src",
105-
"tests",
102+
minversion = "8"
103+
addopts = [
104+
"-ra",
105+
"--showlocals",
106+
"--strict-markers",
107+
"--strict-config",
108+
"--doctest-modules"
106109
]
110+
xfail_strict = true
111+
filterwarnings = ["error"]
112+
log_cli_level = "info"
113+
testpaths = ["src", "tests"]
107114

108115

109116
[tool.coverage]
@@ -126,6 +133,8 @@ Path = "pathlib"
126133

127134
[tool.mypy]
128135
strict = true
136+
warn_unreachable = false
137+
enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"]
129138
disable_error_code = ["type-arg"]
130139

131140
# Don't type test suite itself but check if usage makes sense with docstub's stubs

src/docstub/_cli.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ def _collect_type_info(root_path, *, ignore=(), cache=False):
122122
collect = TypeCollector.collect
123123

124124
for source_path in walk_source_package(root_path, ignore=ignore):
125-
126125
if cache:
127126
module = source_path.relative_to(root_path.parent)
128127
collect.sub_dir = f"{__version__}/{module}"

src/docstub/_stubs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@
2424
def try_format_stub(stub: str) -> str:
2525
"""Try to format a stub file with isort and black if available."""
2626
try:
27-
import isort
27+
import isort # noqa: PLC0415
2828

2929
stub = isort.code(stub)
3030
except ImportError:
3131
logger.warning("isort is not available, couldn't sort imports")
3232
try:
33-
import black
33+
import black # noqa: PLC0415
3434

3535
stub = black.format_str(stub, mode=black.Mode(is_pyi=True))
3636
except ImportError:

src/docstub/_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ def format_location(*, path, line, column):
235235

236236
@staticmethod
237237
def underline(line):
238-
underlined = f"{line}\n" f"{click.style('^' * len(line), fg='red', bold=True)}"
238+
underlined = f"{line}\n{click.style('^' * len(line), fg='red', bold=True)}"
239239
return underlined
240240

241241

tests/test_cache.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ def test_create_validate_cache(tmp_path):
4848

4949
class Test_FileCache:
5050
def test_basic(self, tmp_path):
51-
5251
class Serializer:
5352
suffix = ".txt"
5453

tests/test_docs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def test_command_line_reference(command, name):
7070
with md_file.open("r") as io:
7171
md_content = io.read()
7272

73-
guard_name = f"cli-{name.replace(" ", "-")}"
73+
guard_name = f"cli-{name.replace(' ', '-')}"
7474
regex = rf"<!--- begin {guard_name} --->(.*)<!--- end {guard_name} --->"
7575
matches = re.findall(regex, md_content, flags=re.DOTALL)
7676
assert len(matches) == 1

0 commit comments

Comments
 (0)