Skip to content

Commit 260eac3

Browse files
committed
Fix Python 3.9-incompatible union syntax
1 parent a1f6d3a commit 260eac3

5 files changed

Lines changed: 11 additions & 9 deletions

File tree

src/attr/_make.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,12 @@ def __reduce__(self, _none_constructor=type(None), _args=()): # noqa: B008
105105

106106
class _TupleProxy(Sequence):
107107
"""A wrapper for a tuple that makes it not type-check as a tuple
108-
108+
109109
This is a hack to make Sphinx document all cached properties on slots
110110
classes as if they were regular properties.
111-
111+
112112
"""
113+
113114
__slots__ = ("_tup",)
114115

115116
def __init__(self, tup: tuple):

src/attrs/sphinx_cached_property.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
classes will be inaccessible.
77
88
"""
9+
10+
from __future__ import annotations
11+
912
from functools import cached_property
1013
from typing import Any
1114

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
.. autoclass:: tests.test_slots.SphinxDocTest
22

3-
.. autoproperty:: documented
3+
.. autoproperty:: documented
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
.. autoclass:: tests.test_slots.SphinxDocTest
2-
:members:
2+
:members:

tests/test_slots.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,22 @@
88
import pickle
99
import shutil
1010
import weakref
11-
from itertools import zip_longest
1211

12+
from itertools import zip_longest
1313
from pathlib import Path
1414
from unittest import mock
1515

1616
import hypothesis.strategies as st
1717
import pytest
18-
from hypothesis import given
19-
20-
from attr._make import _TupleProxy
21-
2218

19+
from hypothesis import given
2320
from sphinx.application import Sphinx
2421

2522
import attr
2623
import attrs
2724

2825
from attr._compat import PY_3_14_PLUS, PYPY
26+
from attr._make import _TupleProxy
2927

3028

3129
# Pympler doesn't work on PyPy.

0 commit comments

Comments
 (0)