Skip to content

Commit

Permalink
Python support (#151)
Browse files Browse the repository at this point in the history
* Python support (#150)
* limit pygments
  • Loading branch information
felix-hilden authored Jan 8, 2025
1 parent 6747259 commit 5203bdf
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 28 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ on:
branches:
- master
tags-ignore:
- '*'
- "*"
pull_request:

jobs:
matrix:
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10"]
python-version: ["3.9", "3.10", "3.11", "3.12"]
name: Pytest on ${{matrix.python-version}}
runs-on: ubuntu-latest

Expand All @@ -34,14 +34,14 @@ jobs:
run: pytest

full-build:
name: Full 3.11 build
name: Full 3.13 build
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.11"
python-version: "3.13"
- name: Install package
run: |
python -m pip install --upgrade pip
Expand Down
7 changes: 2 additions & 5 deletions docs/src/about.rst
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,8 @@ outermost ``div`` tag. For example:
codeautolink_search_css_classes = ["highlight-default"]
Secondly, matching can fail on a specific line or range of lines.
This is often a bug, but the known expected failure cases are presented here:

- Multiline statements cannot be matched on Python versions before 3.8.
This is because the builtin AST parser does not supply the necessary line
number information to construct the proper search range.
This is often a bug, but the known expected failure cases are presented here
(none currently).

Debugging missing links
-----------------------
Expand Down
5 changes: 5 additions & 0 deletions docs/src/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ These release notes are based on
sphinx-codeautolink adheres to
`Semantic Versioning <https://semver.org>`_.

Unreleased
----------
- Declare support for Python 3.12 and 3.13 (:issue:`150`)
- Remove support for Python 3.7 and 3.8 (:issue:`150`)

0.15.2 (2024-06-03)
-------------------
- Fix matching of ``import a, b`` (:issue:`142`)
Expand Down
7 changes: 4 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ readme = "readme_pypi.rst"
license = {file = "LICENSE"}
dynamic = ["version"]

requires-python = ">=3.7"
requires-python = ">=3.9"
dependencies = [
"sphinx>=3.2.0",
"beautifulsoup4>=4.8.1",
"pygments<2.19",
]
# Keep extras in sync with requirements manually
optional-dependencies = {ipython = ["ipython!=8.7.0"]}
Expand All @@ -26,11 +27,11 @@ classifiers = [
"Framework :: Sphinx :: Extension",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Topic :: Documentation",
"Topic :: Documentation :: Sphinx",
"Topic :: Software Development :: Documentation",
Expand Down
5 changes: 1 addition & 4 deletions src/sphinx_codeautolink/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

from .warn import logger, warn_type

HAS_WALRUS = sys.version_info >= (3, 8)
HAS_MATCH = sys.version_info >= (3, 10)


Expand Down Expand Up @@ -277,9 +276,7 @@ def reset_parents(self):
self._parents = old

# Nodes that are excempt from resetting parents in default visit
track_nodes = (ast.Name, ast.Attribute, ast.Call)
if HAS_WALRUS:
track_nodes += (ast.NamedExpr,)
track_nodes = (ast.Name, ast.Attribute, ast.Call, ast.NamedExpr)
if HAS_MATCH:
track_nodes += (ast.MatchAs,)

Expand Down
4 changes: 0 additions & 4 deletions tests/parse/_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@

from sphinx_codeautolink.parse import parse_names

skip_walrus = pytest.mark.skipif(
sys.version_info < (3, 8), reason="Walrus introduced in Python 3.8."
)

skip_type_union = pytest.mark.skipif(
sys.version_info < (3, 10), reason="Type union introduced in Python 3.10."
)
Expand Down
7 changes: 1 addition & 6 deletions tests/parse/assign.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest

from ._util import refs_equal, skip_walrus
from ._util import refs_equal


class TestAssign:
Expand Down Expand Up @@ -164,35 +164,30 @@ def test_annassign_without_value_overrides_annotation_but_not_linked(self):
refs = [("a", "a")]
return s, refs

@skip_walrus
@refs_equal
def test_walrus_uses_imported(self):
s = "import a\n(a := 1)\na"
refs = [("a", "a")]
return s, refs

@skip_walrus
@refs_equal
def test_walrus_uses_and_assigns_imported(self):
s = "import a\n(a := a)\na"
refs = [("a", "a"), ("a", "a"), ("a", "a"), ("a", "a")]
return s, refs

@skip_walrus
@refs_equal
def test_walrus_uses_and_assigns_modified_imported(self):
s = "import a\n(a := a + 1)\na"
refs = [("a", "a"), ("a", "a")]
return s, refs

@skip_walrus
@refs_equal
def test_nested_walrus_statements(self):
s = "import a\n(c := (b := a))"
refs = [("a", "a"), ("a", "a"), ("a", "b"), ("a", "c")]
return s, refs

@skip_walrus
@refs_equal
def test_walrus_result_assigned(self):
s = "import a\nc = (b := a)"
Expand Down
3 changes: 1 addition & 2 deletions tests/parse/scope.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest

from ._util import refs_equal, skip_type_union, skip_walrus
from ._util import refs_equal, skip_type_union


class TestFunction:
Expand Down Expand Up @@ -258,7 +258,6 @@ def test_multicomp_uses_then_overrides(self):
refs = [("a", "a"), ("a", "a")]
return s, refs

@skip_walrus
@pytest.mark.xfail(reason='Assignments are not tracked outside of a "scope".')
@refs_equal
def test_comp_leaks_walrus(self):
Expand Down

0 comments on commit 5203bdf

Please sign in to comment.