Skip to content

Commit 86d7e7e

Browse files
authored
Merge branch 'main' into evolve-inherited-fields
2 parents 76a8e8c + ca3fb0e commit 86d7e7e

File tree

5 files changed

+256
-206
lines changed

5 files changed

+256
-206
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ci:
44

55
repos:
66
- repo: https://github.com/astral-sh/ruff-pre-commit
7-
rev: v0.11.12
7+
rev: v0.12.0
88
hooks:
99
- id: ruff-check
1010
args: [--fix, --exit-non-zero-on-fix]

pyproject.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,9 @@ toplevel = ["attr", "attrs"]
203203
src = ["src", "tests", "conftest.py", "docs"]
204204
line-length = 79
205205

206+
[tool.ruff.per-file-target-version]
207+
"tests/test_pattern_matching.py" = "py310"
208+
206209
[tool.ruff.lint]
207210
select = ["ALL"]
208211
ignore = [
@@ -221,6 +224,7 @@ ignore = [
221224
"ISC001", # conflicts with ruff format
222225
"N", # we need more naming freedom
223226
"PD", # we're not pandas
227+
"PLC0415", # sometimes, imports have to live elsewhere
224228
"PLR0912", # we're complex software
225229
"PLR0913", # yes, many arguments, but most have defaults
226230
"PLR0915", # we're complex software
@@ -247,6 +251,7 @@ ignore = [
247251
"DTZ", # datetime best practices don't matter in tests
248252
"EM", # no need for exception msg hygiene in tests
249253
"PLE0309", # hash doesn't have to return anything in tests
254+
"PLW1641", # it's OK to rely object's __hash__
250255
"PLR0124", # pointless comparison in tests aren't pointless
251256
"PT011", # broad is fine
252257
"PT012", # sometimes we need more than a single stmt

src/attr/_version_info.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,6 @@ def __lt__(self, other):
8484
# Since alphabetically "dev0" < "final" < "post1" < "post2", we don't
8585
# have to do anything special with releaselevel for now.
8686
return us < them
87+
88+
def __hash__(self):
89+
return hash((self.year, self.minor, self.micro, self.releaselevel))

tests/test_version_info.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88

99
@pytest.fixture(name="vi")
10-
def fixture_vi():
10+
def _vi():
1111
return VersionInfo(19, 2, 0, "final")
1212

1313

@@ -55,3 +55,9 @@ def test_order(self, vi):
5555
assert vi >= (19, 2)
5656
assert vi > (19, 2, 0, "dev0")
5757
assert vi < (19, 2, 0, "post1")
58+
59+
def test_hash(self, vi):
60+
"""
61+
Same values, same hash.
62+
"""
63+
assert hash(vi) == hash(VersionInfo(19, 2, 0, "final"))

0 commit comments

Comments
 (0)