From 3935da6535a95d3d6c8937b2cee6e58e2953c6ca Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Fri, 4 Aug 2023 09:17:54 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20Update=20pre-commit=20hooks=20(#?= =?UTF-8?q?956)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .pre-commit-config.yaml | 8 ++++---- noxfile.py | 7 +++++++ sphinx_needs/api/need.py | 3 --- sphinx_needs/directives/needextend.py | 1 - sphinx_needs/directives/needextract.py | 1 - sphinx_needs/need_constraints.py | 4 ---- sphinx_needs/services/open_needs.py | 1 - tests/test_layouts.py | 1 - tests/test_needs_external_needs_build.py | 2 -- tests/test_role_need_max_title_length.py | 2 -- tests/test_services/test_service_basics.py | 2 -- tests/test_title_from_content.py | 1 - tests/test_title_optional.py | 1 - 13 files changed, 11 insertions(+), 23 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 016660f79..fcc989675 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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: @@ -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: @@ -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 diff --git a/noxfile.py b/noxfile.py index 01c35262a..0310406d5 100644 --- a/noxfile.py +++ b/noxfile.py @@ -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) diff --git a/sphinx_needs/api/need.py b/sphinx_needs/api/need.py index a143bde28..7ff872d94 100644 --- a/sphinx_needs/api/need.py +++ b/sphinx_needs/api/need.py @@ -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)] @@ -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)] @@ -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 diff --git a/sphinx_needs/directives/needextend.py b/sphinx_needs/directives/needextend.py index b7d8e1b5e..4bb7400fb 100644 --- a/sphinx_needs/directives/needextend.py +++ b/sphinx_needs/directives/needextend.py @@ -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"] diff --git a/sphinx_needs/directives/needextract.py b/sphinx_needs/directives/needextract.py index 7a732633e..c02c10cb1 100644 --- a/sphinx_needs/directives/needextract.py +++ b/sphinx_needs/directives/needextract.py @@ -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. diff --git a/sphinx_needs/need_constraints.py b/sphinx_needs/need_constraints.py index 87cf6b8ae..ca5f2ebe4 100644 --- a/sphinx_needs/need_constraints.py +++ b/sphinx_needs/need_constraints.py @@ -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] @@ -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) @@ -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" diff --git a/sphinx_needs/services/open_needs.py b/sphinx_needs/services/open_needs.py index 4733eb7e2..a5d9512ae 100644 --- a/sphinx_needs/services/open_needs.py +++ b/sphinx_needs/services/open_needs.py @@ -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 diff --git a/tests/test_layouts.py b/tests/test_layouts.py index 28639c679..e20aca3f7 100644 --- a/tests/test_layouts.py +++ b/tests/test_layouts.py @@ -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. diff --git a/tests/test_needs_external_needs_build.py b/tests/test_needs_external_needs_build.py index 785887d56..4dfc21878 100644 --- a/tests/test_needs_external_needs_build.py +++ b/tests/test_needs_external_needs_build.py @@ -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" @@ -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" diff --git a/tests/test_role_need_max_title_length.py b/tests/test_role_need_max_title_length.py index ea4808b41..c8a9c1616 100644 --- a/tests/test_role_need_max_title_length.py +++ b/tests/test_role_need_max_title_length.py @@ -10,7 +10,6 @@ indirect=True, ) def test_max_title_length_unlimited(test_app): - os.environ["MAX_TITLE_LENGTH"] = "-1" app = test_app @@ -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 diff --git a/tests/test_services/test_service_basics.py b/tests/test_services/test_service_basics.py index ddedcb116..af961353a 100644 --- a/tests/test_services/test_service_basics.py +++ b/tests/test_services/test_service_basics.py @@ -8,7 +8,6 @@ class ServiceTest(BaseService): - options = ["custom_option", "exists"] def __init__(self, _app: Sphinx, _name: str, config, **kwargs) -> None: @@ -42,7 +41,6 @@ def debug(self, options): class NoDebugService(BaseService): - options = [] def __init__(self, _app: Sphinx, _name: str, config, **kwargs): diff --git a/tests/test_title_from_content.py b/tests/test_title_from_content.py index f11c67e68..fe860bed0 100644 --- a/tests/test_title_from_content.py +++ b/tests/test_title_from_content.py @@ -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. diff --git a/tests/test_title_optional.py b/tests/test_title_optional.py index d79cf7392..8bc715add 100644 --- a/tests/test_title_optional.py +++ b/tests/test_title_optional.py @@ -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.