Skip to content

Commit

Permalink
Finalize 3.8 drop
Browse files Browse the repository at this point in the history
  • Loading branch information
hynek committed Jan 20, 2025
1 parent 7720b7c commit a69961d
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ci:

repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.6
rev: v0.9.2
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand Down
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ name = "attrs"
authors = [{ name = "Hynek Schlawack", email = "[email protected]" }]
license = "MIT"
license-files = ["LICENSE"]
requires-python = ">=3.8"
requires-python = ">=3.9"
description = "Classes Without Boilerplate"
keywords = ["class", "attribute", "boilerplate"]
classifiers = [
Expand Down Expand Up @@ -226,6 +226,8 @@ ignore = [
"TD", # we don't follow other people's todo style
"TRY301", # I'm sorry, but this makes not sense for us.
"UP031", # format() is slow as molasses; % and f'' FTW.
"UP006", # replace Dict etc by dict etc later.
"UP035", # replace Dict etc by dict etc later.
]

[tool.ruff.lint.per-file-ignores]
Expand All @@ -242,6 +244,7 @@ ignore = [
"PLR0124", # pointless comparison in tests aren't pointless
"PT011", # broad is fine
"PT012", # sometimes we need more than a single stmt
"RUF009", # using results of function calls as defaults is fine
"RUF012", # we don't do ClassVar annotations in tests
"S", # security concerns don't matter in tests
"SIM201", # sometimes we need to check `not ==`
Expand Down
1 change: 0 additions & 1 deletion src/attr/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@


PYPY = platform.python_implementation() == "PyPy"
PY_3_9_PLUS = sys.version_info[:2] >= (3, 9)
PY_3_10_PLUS = sys.version_info[:2] >= (3, 10)
PY_3_11_PLUS = sys.version_info[:2] >= (3, 11)
PY_3_12_PLUS = sys.version_info[:2] >= (3, 12)
Expand Down
11 changes: 6 additions & 5 deletions src/attr/_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import copy

from ._compat import PY_3_9_PLUS, get_generic_base
from ._compat import get_generic_base
from ._make import _OBJ_SETATTR, NOTHING, fields
from .exceptions import AttrsAttributeNotFoundError

Expand Down Expand Up @@ -450,10 +450,11 @@ class yet.
if getattr(cls, "__attrs_types_resolved__", None) != cls:
import typing

kwargs = {"globalns": globalns, "localns": localns}

if PY_3_9_PLUS:
kwargs["include_extras"] = include_extras
kwargs = {
"globalns": globalns,
"localns": localns,
"include_extras": include_extras,
}

hints = typing.get_type_hints(cls, **kwargs)
for field in fields(cls) if attribs is None else attribs:
Expand Down
2 changes: 1 addition & 1 deletion src/attr/_make.py
Original file line number Diff line number Diff line change
Expand Up @@ -2285,7 +2285,7 @@ def _attrs_to_init_script(
NL = "\n "
return (
f"""def {method_name}(self, {args}):
{NL.join(lines) if lines else 'pass'}
{NL.join(lines) if lines else "pass"}
""",
names_for_globals,
annotations,
Expand Down
5 changes: 3 additions & 2 deletions tests/test_annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import pytest

import attr
import attrs

from attr._compat import PY_3_14_PLUS
from attr._make import _is_class_var
Expand Down Expand Up @@ -107,7 +108,7 @@ def test_auto_attribs(self, slots):
class C:
cls_var: typing.ClassVar[int] = 23
a: int
x: typing.List[int] = attr.Factory(list)
x: typing.List[int] = attrs.Factory(list)
y: int = 2
z: int = attr.ib(default=3)
foo: typing.Any = None
Expand Down Expand Up @@ -407,7 +408,7 @@ class C:
cls_var2: "ClassVar[int]" = 23
cls_var3: "t.ClassVar[int]" = 23
a: "int"
x: "typing.List[int]" = attr.Factory(list)
x: "typing.List[int]" = attrs.Factory(list)
y: "int" = 2
z: "int" = attr.ib(default=3)
foo: "typing.Any" = None
Expand Down
3 changes: 1 addition & 2 deletions tests/test_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -1074,8 +1074,7 @@ def test_repr(self):
v = not_(wrapped)

assert (
f"<not_ validator wrapping {wrapped!r}, "
f"capturing {v.exc_types!r}>"
f"<not_ validator wrapping {wrapped!r}, capturing {v.exc_types!r}>"
) == repr(v)

def test_success_because_fails(self):
Expand Down
2 changes: 1 addition & 1 deletion tests/typing_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ class Validated2:

@attrs.define
class Validated3:
num: int = attr.field(validator=attr.validators.ge(0))
num: int = attrs.field(validator=attr.validators.ge(0))


with attr.validators.disabled():
Expand Down
6 changes: 3 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
min_version = 4
env_list =
pre-commit,
py3{8,9,10,11,12,13}-tests,
py3{9,10,11,12,13}-tests,
py3{10,11,12,13}-mypy,
pypy3-tests,
pyright,
Expand Down Expand Up @@ -31,7 +31,7 @@ commands =
dependency_groups = tests
commands = pytest tests/test_functional.py

[testenv:py3{8,10,13}-tests]
[testenv:py3{9,10,13}-tests]
dependency_groups = cov
# Python 3.6+ has a number of compile-time warnings on invalid string escapes.
# PYTHONWARNINGS=d makes them visible during the tox run.
Expand All @@ -46,7 +46,7 @@ commands =
# Keep base_python in-sync with .python-version-default
base_python = py313
# Keep depends in-sync with testenv above that has the cov dependency group.
depends = py3{8,10,13}-tests
depends = py3{9,10,13}-tests
skip_install = true
dependency_groups = cov
commands =
Expand Down

0 comments on commit a69961d

Please sign in to comment.