Skip to content

Commit

Permalink
Add Python 3.12 and PyPy 3.10 support. (#283)
Browse files Browse the repository at this point in the history
* Add Python 3.12 and PyPy 3.10 support.

* Also use 3.12 in publish.

* Silence flake8 E231 for ::.

* Remove pkg_resources usage from tests.
  • Loading branch information
wRAR authored Oct 5, 2023
1 parent 7989199 commit 0475327
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 18 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@ jobs:
fail-fast: false
matrix:
include:
- python-version: "3.11"
- python-version: "3.12"
env:
TOXENV: security
- python-version: "3.11"
- python-version: "3.12"
env:
TOXENV: flake8
- python-version: "3.11"
- python-version: "3.12"
env:
TOXENV: pylint
- python-version: "3.11" # Keep in sync with .readthedocs.yml
env:
TOXENV: docs
- python-version: "3.11"
- python-version: "3.12"
env:
TOXENV: typing
- python-version: "3.11"
- python-version: "3.12"
env:
TOXENV: black
- python-version: "3.11"
- python-version: "3.12"
env:
TOXENV: twinecheck

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Set up Python 3.10
- name: Set up Python 3.12
uses: actions/setup-python@v4
with:
python-version: "3.10"
python-version: "3.12"

- name: Check Tag
id: check-release-tag
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,18 @@ jobs:
- python-version: "3.11"
env:
TOXENV: py
- python-version: pypy3.9
- python-version: "3.12"
env:
TOXENV: py
- python-version: pypy3.10
env:
TOXENV: pypy3

steps:
- uses: actions/checkout@v4

- name: Install system libraries
if: contains(matrix.python-version, 'pypy3.9')
if: contains(matrix.python-version, 'pypy')
run: |
sudo apt-get update
sudo apt-get install libxml2-dev libxslt-dev
Expand Down
6 changes: 3 additions & 3 deletions parsel/csstranslator.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,15 @@ def xpath_pseudo_element(
method = getattr(self, method_name, None)
if not method:
raise ExpressionError(
f"The functional pseudo-element ::{pseudo_element.name}() is unknown"
f"The functional pseudo-element ::{pseudo_element.name}() is unknown" # noqa: E231
)
xpath = method(xpath, pseudo_element)
else:
method_name = f"xpath_{pseudo_element.replace('-', '_')}_simple_pseudo_element"
method = getattr(self, method_name, None)
if not method:
raise ExpressionError(
f"The pseudo-element ::{pseudo_element} is unknown"
f"The pseudo-element ::{pseudo_element} is unknown" # noqa: E231
)
xpath = method(xpath)
return xpath
Expand All @@ -119,7 +119,7 @@ def xpath_attr_functional_pseudo_element(
"""Support selecting attribute values using ::attr() pseudo-element"""
if function.argument_types() not in (["STRING"], ["IDENT"]):
raise ExpressionError(
f"Expected a single string or ident for ::attr(), got {function.arguments!r}"
f"Expected a single string or ident for ::attr(), got {function.arguments!r}" # noqa: E231
)
return XPathExpr.from_xpath(
xpath, attribute=function.arguments[0].value
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
],
Expand Down
6 changes: 3 additions & 3 deletions tests/test_selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from lxml import etree
from lxml.html import HtmlElement
from pkg_resources import parse_version
from packaging.version import Version

from parsel import Selector, SelectorList
from parsel.selector import (
Expand Down Expand Up @@ -1115,8 +1115,8 @@ def test_remove_root_element_selector(self) -> None:
self.assertEqual(sel.get(), "<html></html>")

def test_deep_nesting(self) -> None:
lxml_version = parse_version(etree.__version__)
lxml_huge_tree_version = parse_version("4.2")
lxml_version = Version(etree.__version__)
lxml_huge_tree_version = Version("4.2")

content = """
<html>
Expand Down
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = security,flake8,typing,pylint,black,docs,twinecheck,py37,py38,py39,py310,pypy3.9
envlist = security,flake8,typing,pylint,black,docs,twinecheck,py38,py39,py310,py311,py312,pypy3.9,pypy3.10

[testenv]
usedevelop = True
Expand Down Expand Up @@ -35,7 +35,7 @@ commands =
[testenv:pylint]
deps =
{[testenv]deps}
pylint==2.15.4
pylint==3.0.0
commands =
pylint docs parsel tests setup.py

Expand Down

0 comments on commit 0475327

Please sign in to comment.