Skip to content

Commit 5203bdf

Browse files
authored
Python support (#151)
* Python support (#150) * limit pygments
1 parent 6747259 commit 5203bdf

File tree

8 files changed

+18
-28
lines changed

8 files changed

+18
-28
lines changed

.github/workflows/CI.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ on:
88
branches:
99
- master
1010
tags-ignore:
11-
- '*'
11+
- "*"
1212
pull_request:
1313

1414
jobs:
1515
matrix:
1616
strategy:
1717
matrix:
18-
python-version: ["3.7", "3.8", "3.9", "3.10"]
18+
python-version: ["3.9", "3.10", "3.11", "3.12"]
1919
name: Pytest on ${{matrix.python-version}}
2020
runs-on: ubuntu-latest
2121

@@ -34,14 +34,14 @@ jobs:
3434
run: pytest
3535

3636
full-build:
37-
name: Full 3.11 build
37+
name: Full 3.13 build
3838
runs-on: ubuntu-20.04
3939
steps:
4040
- uses: actions/checkout@v2
4141
- name: Set up Python
4242
uses: actions/setup-python@v2
4343
with:
44-
python-version: "3.11"
44+
python-version: "3.13"
4545
- name: Install package
4646
run: |
4747
python -m pip install --upgrade pip

docs/src/about.rst

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,8 @@ outermost ``div`` tag. For example:
107107
codeautolink_search_css_classes = ["highlight-default"]
108108
109109
Secondly, matching can fail on a specific line or range of lines.
110-
This is often a bug, but the known expected failure cases are presented here:
111-
112-
- Multiline statements cannot be matched on Python versions before 3.8.
113-
This is because the builtin AST parser does not supply the necessary line
114-
number information to construct the proper search range.
110+
This is often a bug, but the known expected failure cases are presented here
111+
(none currently).
115112

116113
Debugging missing links
117114
-----------------------

docs/src/release_notes.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ These release notes are based on
88
sphinx-codeautolink adheres to
99
`Semantic Versioning <https://semver.org>`_.
1010

11+
Unreleased
12+
----------
13+
- Declare support for Python 3.12 and 3.13 (:issue:`150`)
14+
- Remove support for Python 3.7 and 3.8 (:issue:`150`)
15+
1116
0.15.2 (2024-06-03)
1217
-------------------
1318
- Fix matching of ``import a, b`` (:issue:`142`)

pyproject.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ readme = "readme_pypi.rst"
99
license = {file = "LICENSE"}
1010
dynamic = ["version"]
1111

12-
requires-python = ">=3.7"
12+
requires-python = ">=3.9"
1313
dependencies = [
1414
"sphinx>=3.2.0",
1515
"beautifulsoup4>=4.8.1",
16+
"pygments<2.19",
1617
]
1718
# Keep extras in sync with requirements manually
1819
optional-dependencies = {ipython = ["ipython!=8.7.0"]}
@@ -26,11 +27,11 @@ classifiers = [
2627
"Framework :: Sphinx :: Extension",
2728
"Programming Language :: Python :: 3",
2829
"Programming Language :: Python :: 3 :: Only",
29-
"Programming Language :: Python :: 3.7",
30-
"Programming Language :: Python :: 3.8",
3130
"Programming Language :: Python :: 3.9",
3231
"Programming Language :: Python :: 3.10",
3332
"Programming Language :: Python :: 3.11",
33+
"Programming Language :: Python :: 3.12",
34+
"Programming Language :: Python :: 3.13",
3435
"Topic :: Documentation",
3536
"Topic :: Documentation :: Sphinx",
3637
"Topic :: Software Development :: Documentation",

src/sphinx_codeautolink/parse.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
from .warn import logger, warn_type
1414

15-
HAS_WALRUS = sys.version_info >= (3, 8)
1615
HAS_MATCH = sys.version_info >= (3, 10)
1716

1817

@@ -277,9 +276,7 @@ def reset_parents(self):
277276
self._parents = old
278277

279278
# Nodes that are excempt from resetting parents in default visit
280-
track_nodes = (ast.Name, ast.Attribute, ast.Call)
281-
if HAS_WALRUS:
282-
track_nodes += (ast.NamedExpr,)
279+
track_nodes = (ast.Name, ast.Attribute, ast.Call, ast.NamedExpr)
283280
if HAS_MATCH:
284281
track_nodes += (ast.MatchAs,)
285282

tests/parse/_util.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@
55

66
from sphinx_codeautolink.parse import parse_names
77

8-
skip_walrus = pytest.mark.skipif(
9-
sys.version_info < (3, 8), reason="Walrus introduced in Python 3.8."
10-
)
11-
128
skip_type_union = pytest.mark.skipif(
139
sys.version_info < (3, 10), reason="Type union introduced in Python 3.10."
1410
)

tests/parse/assign.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import pytest
22

3-
from ._util import refs_equal, skip_walrus
3+
from ._util import refs_equal
44

55

66
class TestAssign:
@@ -164,35 +164,30 @@ def test_annassign_without_value_overrides_annotation_but_not_linked(self):
164164
refs = [("a", "a")]
165165
return s, refs
166166

167-
@skip_walrus
168167
@refs_equal
169168
def test_walrus_uses_imported(self):
170169
s = "import a\n(a := 1)\na"
171170
refs = [("a", "a")]
172171
return s, refs
173172

174-
@skip_walrus
175173
@refs_equal
176174
def test_walrus_uses_and_assigns_imported(self):
177175
s = "import a\n(a := a)\na"
178176
refs = [("a", "a"), ("a", "a"), ("a", "a"), ("a", "a")]
179177
return s, refs
180178

181-
@skip_walrus
182179
@refs_equal
183180
def test_walrus_uses_and_assigns_modified_imported(self):
184181
s = "import a\n(a := a + 1)\na"
185182
refs = [("a", "a"), ("a", "a")]
186183
return s, refs
187184

188-
@skip_walrus
189185
@refs_equal
190186
def test_nested_walrus_statements(self):
191187
s = "import a\n(c := (b := a))"
192188
refs = [("a", "a"), ("a", "a"), ("a", "b"), ("a", "c")]
193189
return s, refs
194190

195-
@skip_walrus
196191
@refs_equal
197192
def test_walrus_result_assigned(self):
198193
s = "import a\nc = (b := a)"

tests/parse/scope.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import pytest
22

3-
from ._util import refs_equal, skip_type_union, skip_walrus
3+
from ._util import refs_equal, skip_type_union
44

55

66
class TestFunction:
@@ -258,7 +258,6 @@ def test_multicomp_uses_then_overrides(self):
258258
refs = [("a", "a"), ("a", "a")]
259259
return s, refs
260260

261-
@skip_walrus
262261
@pytest.mark.xfail(reason='Assignments are not tracked outside of a "scope".')
263262
@refs_equal
264263
def test_comp_leaks_walrus(self):

0 commit comments

Comments
 (0)