Skip to content

Commit

Permalink
🔧 Update pre-commit hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisjsewell committed Aug 3, 2023
1 parent 01f0e5d commit 80d01c2
Show file tree
Hide file tree
Showing 14 changed files with 11 additions and 24 deletions.
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
repos:
- repo: https://github.com/psf/black
rev: 22.12.0
rev: 23.7.0
hooks:
- id: black

- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
rev: 6.1.0
hooks:
- id: flake8
additional_dependencies:
Expand All @@ -20,7 +20,7 @@ repos:
- id: isort

- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
rev: v3.10.1
hooks:
- id: pyupgrade
args:
Expand All @@ -36,6 +36,6 @@ repos:
pass_filenames: false

- repo: https://github.com/python-poetry/poetry
rev: 1.3.0
rev: 1.5.0
hooks:
- id: poetry-check
7 changes: 7 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,10 @@ def benchmark_memory(session):
env={"ON_CI": "true", "FAST_BUILD": "true"},
)
session.run("memray", "flamegraph", "-o", "mem_out.html", "mem_out.bin")


@session(python="3.8")
def pre_commit(session):
session.run_always("poetry", "install", external=True)
session.install("pre-commit")
session.run("pre-commit", "run", "--all-files", external=True)
3 changes: 0 additions & 3 deletions sphinx_needs/api/need.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ def run():
if tags is None:
tags = []
if len(tags) > 0:

# tags should be a string, but it can also be already a list, which can be used.
if isinstance(tags, str):
tags = [tag.strip() for tag in re.split("[;,]", tags)]
Expand Down Expand Up @@ -238,7 +237,6 @@ def run():
if constraints is None:
constraints = []
if len(constraints) > 0:

# tags should be a string, but it can also be already a list,which can be used.
if isinstance(constraints, str):
constraints = [constraint.strip() for constraint in re.split("[;,]", constraints)]
Expand Down Expand Up @@ -733,7 +731,6 @@ def _merge_global_options(app: Sphinx, needs_info, global_options) -> None:
if global_options is None:
return
for key, value in global_options.items():

# If key already exists in needs_info, this global_option got overwritten manually in current need
if key in needs_info and needs_info[key]:
continue
Expand Down
1 change: 0 additions & 1 deletion sphinx_needs/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ def get_target_uri(self, _docname: str, _typ: Optional[str] = None) -> str:


def build_needs_json(app: Sphinx, _exception: Exception) -> None:

env = unwrap(app.env)

if not env.config.needs_build_json:
Expand Down
1 change: 0 additions & 1 deletion sphinx_needs/directives/needextend.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ def process_needextend(app: Sphinx, doctree: nodes.document, fromdocname: str) -
link_names = [x["option"] for x in app.config.needs_extra_links]

for current_needextend in env.need_all_needextend.values():

# Check if filter is just a need-id.
# In this case create the needed filter string
need_filter = current_needextend["filter"]
Expand Down
1 change: 0 additions & 1 deletion sphinx_needs/directives/needextract.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ def process_needextract(app: Sphinx, doctree: nodes.document, fromdocname: str,
env = unwrap(app.env)

for node in found_nodes:

if not app.config.needs_include_needs:
# Ok, this is really dirty.
# If we replace a node, docutils checks, if it will not lose any attributes.
Expand Down
4 changes: 0 additions & 4 deletions sphinx_needs/need_constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,12 @@ def process_constraints(app: Sphinx, need: Dict[str, Any]) -> None:
constraints = need["constraints"]

for constraint in constraints:

# check if constraint is defined in config
if constraint not in config_constraints.keys():
raise NeedsConstraintNotAllowed(
f"Constraint {constraint} of need id {need_id} is not allowed by config value 'needs_constraints'."
)
else:

# access constraints defined in conf.py
executable_constraints = config_constraints[constraint]

Expand All @@ -42,7 +40,6 @@ def process_constraints(app: Sphinx, need: Dict[str, Any]) -> None:
for name, cmd in executable_constraints.items():
# compile constraint and check single need if it fulfills constraint
if name != "severity":

# check current need if it meets constraint given in check_0, check_1 in conf.py ...
constraint_passed = filter_single_need(app, need, cmd)
results_list.append(constraint_passed)
Expand Down Expand Up @@ -76,7 +73,6 @@ def process_constraints(app: Sphinx, need: Dict[str, Any]) -> None:
)

if "break" in actions_on_fail:

raise NeedsConstraintFailed(
f"FAILED a breaking constraint: >> {cmd} << for need "
f"{need_id} FAILED! breaking build process"
Expand Down
1 change: 0 additions & 1 deletion sphinx_needs/services/open_needs.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ class OpenNeedsService(BaseService):
options = CONFIG_OPTIONS + EXTRA_DATA_OPTIONS + EXTRA_LINK_OPTIONS

def __init__(self, app: Sphinx, name: str, config: Dict[str, Any], **kwargs: Any) -> None:

self.app = app
self.name = name
self.config = config
Expand Down
1 change: 0 additions & 1 deletion tests/test_layouts.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

@pytest.mark.parametrize("test_app", [{"buildername": "html", "srcdir": "doc_test/doc_layout"}], indirect=True)
def test_doc_build_html(test_app):

# Somehow the xml-tree in extract_needs_from_html() works not correctly with py37 and specific
# extracts, which are needed for sphinx >3.0 only.
# Everything with Py3.8 is fine again and also Py3.7 with sphinx<3 works here.
Expand Down
2 changes: 0 additions & 2 deletions tests/test_needs_external_needs_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ def test_external_needs_base_url_relative_path(test_app):

# check needflow usage for base_url in root level
if not sphinx.__version__.startswith("3.5"):

if int(doc_ver.split(".")[1]) >= 18:
root_flow_hrefs = root_tree.xpath("//figure/p/object/a/img")
assert root_tree.xpath("//figure/figcaption/p/span/a")[0].text == "My needflow"
Expand Down Expand Up @@ -192,7 +191,6 @@ def test_external_needs_base_url_relative_path(test_app):

# check needflow usage for base_url in subsubfolder level
if not sphinx.__version__.startswith("3.5"):

if int(doc_ver.split(".")[1]) >= 18:
sub_sub_flow_hrefs = sub_sub_tree.xpath("//figure/p/object/a/img")
assert sub_sub_tree.xpath("//figure/figcaption/p/span/a")[0].text == "My needflow"
Expand Down
2 changes: 0 additions & 2 deletions tests/test_role_need_max_title_length.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
indirect=True,
)
def test_max_title_length_unlimited(test_app):

os.environ["MAX_TITLE_LENGTH"] = "-1"

app = test_app
Expand All @@ -27,7 +26,6 @@ def test_max_title_length_unlimited(test_app):
"test_app", [{"buildername": "html", "srcdir": "doc_test/doc_role_need_max_title_length"}], indirect=True
)
def test_max_title_length_10(test_app):

os.environ["MAX_TITLE_LENGTH"] = "10"

app = test_app
Expand Down
2 changes: 0 additions & 2 deletions tests/test_services/test_service_basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@


class ServiceTest(BaseService):

options = ["custom_option", "exists"]

def __init__(self, _app: Sphinx, _name: str, config, **kwargs) -> None:
Expand Down Expand Up @@ -42,7 +41,6 @@ def debug(self, options):


class NoDebugService(BaseService):

options = []

def __init__(self, _app: Sphinx, _name: str, config, **kwargs):
Expand Down
1 change: 0 additions & 1 deletion tests/test_title_from_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

@pytest.mark.parametrize("test_app", [{"buildername": "html", "srcdir": "doc_test/title_from_content"}], indirect=True)
def test_title_from_content_scenarios(test_app):

# Somehow the xml-tree in extract_needs_from_html() works not correctly with py37 and specific
# extracts, which are needed for sphinx >3.0 only.
# Everything with Py3.8 is fine again and also Py3.7 with sphinx<3 works here.
Expand Down
1 change: 0 additions & 1 deletion tests/test_title_optional.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ def title(self):

@pytest.mark.parametrize("test_app", [{"buildername": "html", "srcdir": "doc_test/title_optional"}], indirect=True)
def test_title_optional_scenarios(test_app):

# Somehow the xml-tree in extract_needs_from_html() works not correctly with py37 and specific
# extracts, which are needed for sphinx >3.0 only.
# Everything with Py3.8 is fine again and also Py3.7 with sphinx<3 works here.
Expand Down

0 comments on commit 80d01c2

Please sign in to comment.