Skip to content

Commit 9f5da02

Browse files
Remove checks for >= python 3.8
1 parent 653ab51 commit 9f5da02

File tree

3 files changed

+10
-17
lines changed

3 files changed

+10
-17
lines changed

src/mkdocstrings_handlers/python_xref/crossref.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2022-2023. Analog Devices Inc.
1+
# Copyright (c) 2022-2024. Analog Devices Inc.
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -28,9 +28,6 @@
2828

2929
logger = get_logger(__name__)
3030

31-
# line numbers from griffe are not reliable before python 3.8; this may eventually be fixed...
32-
_supports_linenums = sys.version_info >= (3,8)
33-
3431
def _re_or(*exps: str) -> str:
3532
"""Construct an "or" regular expression from a sequence of regular expressions.
3633
@@ -309,10 +306,9 @@ def _error(self, msg: str, just_warn: bool = False) -> None:
309306
prefix = f"file://{parent.filepath}:"
310307
line = doc.lineno
311308
if line is not None: # pragma: no branch
312-
if _supports_linenums: # pragma: no branch
313-
# Add line offset to match in docstring. This can still be
314-
# short if the doc string has leading newlines.
315-
line += doc.value.count("\n", 0, self._cur_offset)
309+
# Add line offset to match in docstring. This can still be
310+
# short if the doc string has leading newlines.
311+
line += doc.value.count("\n", 0, self._cur_offset)
316312
prefix += f"{line}:"
317313
# It would be nice to add the column as well, but we cannot determine
318314
# that without knowing how much the doc string was unindented.

tests/test_crossref.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2022. Analog Devices Inc.
1+
# Copyright (c) 2022-2024. Analog Devices Inc.
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -47,8 +47,6 @@ def test_RelativeCrossrefProcessor(caplog: pytest.LogCaptureFixture, monkeypatch
4747
meth1 = Function(name="meth1", parent=cls1)
4848
cls1.members.update(meth1=meth1)
4949

50-
monkeypatch.setattr(mkdocstrings_handlers.python_xref.crossref, '_supports_linenums', True)
51-
5250
def assert_sub(parent: Object, title: str, ref: str,
5351
expected: str = "",
5452
*,

tests/test_integration.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2022. Analog Devices Inc.
1+
# Copyright (c) 2022-2024. Analog Devices Inc.
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -79,11 +79,10 @@ def test_integration(tmpdir: PathLike) -> None:
7979
if os.path.sep == '/':
8080
assert m[1] == str(bar_src_file)
8181
assert m[3] == 'myproj.bar.bad'
82-
if sys.version_info >= (3,8):
83-
# Source location not accurate in python 3.7
84-
bad_line = int(m[2])
85-
bar_lines = bar_src_file.read_text().splitlines()
86-
assert '[bad]' in bar_lines[bad_line - 1]
82+
# Source location not accurate in python 3.7
83+
bad_line = int(m[2])
84+
bar_lines = bar_src_file.read_text().splitlines()
85+
assert '[bad]' in bar_lines[bad_line - 1]
8786

8887
bar_html = site_dir.joinpath('bar', 'index.html').read_text()
8988
bar_bs = bs4.BeautifulSoup(bar_html, 'html.parser')

0 commit comments

Comments
 (0)