Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove Python 3.8 support #123

Merged
merged 3 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
name: "Unit Tests"
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.9", "3.10", "3.11", "3.12"]
runs-on: ["ubuntu-22.04", "windows-2022", "macos-13"]
runs-on: ${{ matrix.runs-on }}
steps:
Expand Down
5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ classifiers = [
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"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",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Software Development :: Quality Assurance"
Expand All @@ -33,7 +34,7 @@ maintainers = [
]
name = "ssort"
readme = "README.rst"
requires-python = ">=3.8"
requires-python = ">=3.9"

[project.license]
text = "MIT"
Expand Down
13 changes: 0 additions & 13 deletions src/ssort/_ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,19 +356,6 @@ def _iter_child_nodes_of_slice(node: ast.Slice) -> Iterable[ast.AST]:
yield node.step


if sys.version_info < (3, 9):

@iter_child_nodes.register(ast.ExtSlice)
def _iter_child_nodes_of_ext_slice(
node: ast.ExtSlice,
) -> Iterable[ast.AST]:
yield from node.dims

@iter_child_nodes.register(ast.Index)
def _iter_child_nodes_of_index(node: ast.Index) -> Iterable[ast.AST]:
yield node.value


@iter_child_nodes.register(ast.comprehension)
def _iter_child_nodes_of_comprehension(
node: ast.comprehension,
Expand Down
7 changes: 3 additions & 4 deletions src/ssort/_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@

import os
import pathlib
from functools import cache
from typing import Iterable

import pathspec

from ssort._utils import memoize

_EMPTY_PATH_SPEC = pathspec.PathSpec([])


@memoize
@cache
def _is_project_root(path: pathlib.Path) -> bool:
if path == path.root or path == path.parent:
return True
Expand All @@ -22,7 +21,7 @@ def _is_project_root(path: pathlib.Path) -> bool:
return False


@memoize
@cache
def _get_ignore_patterns(path: pathlib.Path) -> pathspec.PathSpec:
git_ignore = path / ".gitignore"
if git_ignore.is_file():
Expand Down
5 changes: 0 additions & 5 deletions src/ssort/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@

from ssort._exceptions import UnknownEncodingError

if sys.version_info < (3, 9):
memoize = functools.lru_cache(maxsize=None)
else:
memoize = functools.cache


def sort_key_from_iter(values):
index = {statement: index for index, statement in enumerate(values)}
Expand Down
6 changes: 2 additions & 4 deletions tests/test_ast.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import annotations

import ast
import sys
from typing import Iterable

import pytest
Expand All @@ -13,11 +12,10 @@
ast.AugStore,
ast.Param,
ast.Suite,
ast.Index,
ast.ExtSlice,
)

if sys.version_info >= (3, 9):
_deprecated_node_types += (ast.Index, ast.ExtSlice)

_ignored_node_types: tuple[type[ast.AST], ...] = (
ast.expr_context,
ast.boolop,
Expand Down
22 changes: 1 addition & 21 deletions tests/test_bindings.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,6 @@

from ssort._bindings import get_bindings

# Most walrus operator syntax is valid in 3.8. Only use this decorator for the
# rare cases where it is not.
walrus_operator = pytest.mark.skipif(
sys.version_info < (3, 9),
reason="some walrus operator syntax is not valid prior to python 3.9",
)


match_statement = pytest.mark.skipif(
sys.version_info < (3, 10),
reason="match statements were introduced in python 3.10",
Expand All @@ -35,10 +27,7 @@ def _parse(source):
root = ast.parse(source)
assert len(root.body) == 1
node = root.body[0]
if sys.version_info >= (3, 9):
print(ast.dump(node, include_attributes=True, indent=2))
else:
print(ast.dump(node, include_attributes=True))
print(ast.dump(node, include_attributes=True, indent=2))
return node


Expand Down Expand Up @@ -96,7 +85,6 @@ def function(
]


@walrus_operator
def test_function_def_bindings_walrus_decorator():
node = _parse(
"""
Expand Down Expand Up @@ -165,7 +153,6 @@ async def function(
]


@walrus_operator
def test_async_function_def_bindings_walrus_decorator():
node = _parse(
"""
Expand Down Expand Up @@ -201,7 +188,6 @@ def b(self):
assert list(get_bindings(node)) == ["ClassName"]


@walrus_operator
def test_class_def_bindings_walrus_decorator():
node = _parse(
"""
Expand Down Expand Up @@ -1004,17 +990,11 @@ def test_set_bindings_unpack():
assert list(get_bindings(node)) == []


@walrus_operator
def test_set_bindings_walrus():
node = _parse("{a, {b := genb()}, c}")
assert list(get_bindings(node)) == ["b"]


def test_set_bindings_walrus_py38():
node = _parse("{a, {(b := genb())}, c}")
assert list(get_bindings(node)) == ["b"]


def test_set_bindings_walrus_unpack():
node = _parse("{a, b, *(rest := other)}")
assert list(get_bindings(node)) == ["rest"]
Expand Down
5 changes: 1 addition & 4 deletions tests/test_method_requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ def _method_requirements(source):
root = ast.parse(source)
assert len(root.body) == 1
node = root.body[0]
if sys.version_info >= (3, 9):
print(ast.dump(node, include_attributes=True, indent=2))
else:
print(ast.dump(node, include_attributes=True))
print(ast.dump(node, include_attributes=True, indent=2))
return list(get_method_requirements(node))


Expand Down
5 changes: 1 addition & 4 deletions tests/test_requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ def _parse(source):
root = ast.parse(source)
assert len(root.body) == 1
node = root.body[0]
if sys.version_info >= (3, 9):
print(ast.dump(node, include_attributes=True, indent=2))
else:
print(ast.dump(node, include_attributes=True))
print(ast.dump(node, include_attributes=True, indent=2))
return node


Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py38,py39,py310,py311,py312,black,isort,ssort,pyflakes,pylint,mypy
envlist = py39,py310,py311,py312,black,isort,ssort,pyflakes,pylint,mypy
isolated_build = true

[testenv]
Expand Down