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 1 commit
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
Prev Previous commit
Next Next commit
fix: PR feedback
  • Loading branch information
johnfraney committed Jan 19, 2025
commit e096d64a713bc6d29d49dbb8ff5c5a89bb740692
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
2 changes: 0 additions & 2 deletions src/ssort/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

from ssort._exceptions import UnknownEncodingError

memoize = functools.cache


def sort_key_from_iter(values):
index = {statement: index for index, statement in enumerate(values)}
Expand Down
4 changes: 2 additions & 2 deletions tests/test_ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
ast.AugStore,
ast.Param,
ast.Suite,
ast.Index,
ast.ExtSlice,
)

_deprecated_node_types += (ast.Index, ast.ExtSlice)

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

from ssort._bindings import get_bindings


match_statement = pytest.mark.skipif(
sys.version_info < (3, 10),
reason="match statements were introduced in python 3.10",
Expand Down Expand Up @@ -935,9 +934,7 @@ def test_if_exp_bindings_walrus_alternate():


def test_if_exp_bindings_walrus():
node = _parse(
"(a := subsequent()) if (b := predicate()) else (c := alternate())"
)
node = _parse("(a := subsequent()) if (b := predicate()) else (c := alternate())")
assert list(get_bindings(node)) == ["b", "a", "c"]


Expand Down Expand Up @@ -1069,30 +1066,22 @@ def test_dict_comp_bindings_unpack():


def test_dict_comp_bindings_walrus_key():
node = _parse(
"{(key := item[0]): item[1] for item in iterator if check(item)}"
)
node = _parse("{(key := item[0]): item[1] for item in iterator if check(item)}")
assert list(get_bindings(node)) == ["key"]


def test_dict_comp_bindings_walrus_value():
node = _parse(
"{item[0]: (value := item[1]) for item in iterator if check(item)}"
)
node = _parse("{item[0]: (value := item[1]) for item in iterator if check(item)}")
assert list(get_bindings(node)) == ["value"]


def test_dict_comp_bindings_walrus_iter():
node = _parse(
"{item[0]: item[1] for item in (it := iterator) if check(item)}"
)
node = _parse("{item[0]: item[1] for item in (it := iterator) if check(item)}")
assert list(get_bindings(node)) == ["it"]


def test_dict_comp_bindings_walrus_condition():
node = _parse(
"{item[0]: item[1] for item in iterator if (c := check(item))}"
)
node = _parse("{item[0]: item[1] for item in iterator if (c := check(item))}")
assert list(get_bindings(node)) == ["c"]


Expand Down
Loading