Skip to content

Commit c67c5c8

Browse files
authored
🔧 Update pre-commit hooks (#1109)
Update hooks, fix issues, and also pin dependencies for mypy more strictly (to reduce potential for differences between local and remote runs of mypy)
1 parent f6b090a commit c67c5c8

32 files changed

+104
-85
lines changed

‎.pre-commit-config.yaml‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
repos:
22
- repo: https://github.com/psf/black
3-
rev: 23.10.1
3+
rev: 24.2.0
44
hooks:
55
- id: black
66

77
- repo: https://github.com/PyCQA/flake8
8-
rev: 6.1.0
8+
rev: 7.0.0
99
hooks:
1010
- id: flake8
1111
additional_dependencies:
@@ -15,7 +15,7 @@ repos:
1515
- pep8-naming
1616

1717
- repo: https://github.com/pycqa/isort
18-
rev: 5.12.0
18+
rev: 5.13.2
1919
hooks:
2020
- id: isort
2121

@@ -24,17 +24,18 @@ repos:
2424
hooks:
2525
- id: pyupgrade
2626
args:
27-
- --py36-plus
27+
- --py38-plus
2828

2929
- repo: https://github.com/pre-commit/mirrors-mypy
30-
rev: v1.6.1
30+
rev: v1.8.0
3131
hooks:
3232
- id: mypy
3333
files: sphinx_needs/.*
3434
args: []
3535
additional_dependencies:
36-
- sphinx==6
37-
- types-docutils
36+
- sphinx==6.2.1
37+
- docutils==0.19
38+
- types-docutils==0.20.0.20240201
3839
- types-jsonschema
3940
- types-requests
4041

‎codecov.yml‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
coverage:
2+
status:
3+
project:
4+
default:
5+
target: 80%
6+
threshold: 0.5%
7+
patch:
8+
default:
9+
target: 70%
10+
threshold: 0.5%

‎performance/performance_test.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Executes several performance tests.
33
44
"""
5+
56
import os.path
67
import shutil
78
import subprocess

‎pyproject.toml‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,6 @@ module = [
151151
]
152152
disable_error_code = ["attr-defined", "no-any-return"]
153153

154-
[[tool.mypy.overrides]]
155-
module = [
156-
"sphinx_needs.directives.needextract",
157-
]
158-
disable_error_code = "no-untyped-call"
159-
160154
[build-system]
161155
requires = ["setuptools", "poetry_core>=1.0.8"] # setuptools for deps like plantuml
162156
build-backend = "poetry.core.masonry.api"

‎sphinx_needs/api/configuration.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
44
All functions here are available under ``sphinxcontrib.api``. So do not import this module directly.
55
"""
6+
67
from typing import Callable, List, Optional
78

89
from docutils.parsers.rst import directives

‎sphinx_needs/data.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Module to control access to sphinx-needs data,
22
which is stored in the Sphinx environment.
33
"""
4+
45
from __future__ import annotations
56

67
from typing import TYPE_CHECKING, Literal, TypedDict

‎sphinx_needs/debug.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Contains debug features to track down
33
runtime and other problems with Sphinx-Needs
44
"""
5+
56
from __future__ import annotations
67

78
import inspect

‎sphinx_needs/diagrams_common.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def get_debug_container(puml_node: nodes.Element) -> nodes.container:
140140
"""Return container containing the raw plantuml code"""
141141
debug_container = nodes.container()
142142
if isinstance(puml_node, nodes.figure):
143-
data = puml_node.children[0]["uml"]
143+
data = puml_node.children[0]["uml"] # type: ignore
144144
else:
145145
data = puml_node["uml"]
146146
data = "\n".join([html.escape(line) for line in data.split("\n")])

‎sphinx_needs/directives/need.py‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import hashlib
22
import re
3-
import typing
43
from typing import Any, Dict, List, Optional, Sequence, Tuple
54

65
from docutils import nodes
@@ -240,7 +239,7 @@ def get_sections_and_signature_and_needs(
240239
current_node = need_node
241240
while current_node:
242241
if isinstance(current_node, nodes.section):
243-
title = typing.cast(str, current_node.children[0].astext())
242+
title = current_node.children[0].astext()
244243
# If using auto-section numbering, then Sphinx inserts
245244
# multiple non-breaking space unicode characters into the title
246245
# we'll replace those with a simple space to make them easier to
@@ -344,16 +343,16 @@ def analyse_need_locations(app: Sphinx, doctree: nodes.document) -> None:
344343
# we can remove the hidden needs from the doctree
345344
for need_node in hidden_needs:
346345
if need_node.parent is not None:
347-
need_node.parent.remove(need_node) # type: ignore[attr-defined]
346+
need_node.parent.remove(need_node)
348347

349348

350349
def previous_sibling(node: nodes.Node) -> Optional[nodes.Node]:
351350
"""Return preceding sibling node or ``None``."""
352351
try:
353-
i = node.parent.index(node) # type: ignore
352+
i = node.parent.index(node)
354353
except AttributeError:
355354
return None
356-
return node.parent[i - 1] if i > 0 else None # type: ignore
355+
return node.parent[i - 1] if i > 0 else None
357356

358357

359358
@profile("NEEDS_POST_PROCESS")
@@ -391,7 +390,7 @@ def process_need_nodes(app: Sphinx, doctree: nodes.document, fromdocname: str) -
391390
if not needs_config.include_needs:
392391
for node in doctree.findall(Need):
393392
if node.parent is not None:
394-
node.parent.remove(node) # type: ignore
393+
node.parent.remove(node)
395394
return
396395

397396
needs_data = SphinxNeedsData(app.env)

‎sphinx_needs/directives/needextend.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
33
44
"""
5+
56
import re
67
from typing import Any, Callable, Dict, Sequence
78

0 commit comments

Comments
 (0)