Skip to content

Commit e734558

Browse files
authored
Add attrs namespace (#887)
1 parent a23fe5f commit e734558

33 files changed

+820
-368
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ If your pull request is a documentation fix or a trivial typo, feel free to dele
1919
- [ ] New features have been added to our [Hypothesis testing strategy](https://github.com/python-attrs/attrs/blob/main/tests/strategies.py).
2020
- [ ] Changes or additions to public APIs are reflected in our type stubs (files ending in ``.pyi``).
2121
- [ ] ...and used in the stub test file `tests/typing_example.py`.
22+
- [ ] If they've been added to `attr/__init__.pyi`, they've *also* been re-imported in `attrs/__init__.pyi`.
2223
- [ ] Updated **documentation** for changed code.
2324
- [ ] New functions/classes have to be added to `docs/api.rst` by hand.
2425
- [ ] Changes to the signature of `@attr.s()` have to be added by hand too.

CHANGELOG.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Whenever there is a need to break compatibility, it is announced here in the cha
1212

1313
.. warning::
1414

15-
The structure of the `attr.Attribute` class is exempt from this rule.
15+
The structure of the `attrs.Attribute` class is exempt from this rule.
1616
It *will* change in the future, but since it should be considered read-only, that shouldn't matter.
1717

1818
However if you intend to build extensions on top of ``attrs`` you have to anticipate that.

MANIFEST.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ include LICENSE *.rst *.toml *.yml *.yaml *.ini
22
graft .github
33

44
# Stubs
5-
include src/attr/py.typed
65
recursive-include src *.pyi
6+
recursive-include src py.typed
77

88
# Tests
99
include tox.ini conftest.py

README.rst

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,12 @@ For that, it gives you a class decorator and a way to declaratively define the a
3232
3333
.. code-block:: pycon
3434
35-
>>> from typing import List
36-
>>> from attr import asdict, define, make_class, Factory
35+
>>> from attrs import asdict, define, make_class, Factory
3736
3837
>>> @define
3938
... class SomeClass:
4039
... a_number: int = 42
41-
... list_of_numbers: List[int] = Factory(list)
40+
... list_of_numbers: list[int] = Factory(list)
4241
...
4342
... def hard_math(self, another_number):
4443
... return self.a_number + sum(self.list_of_numbers) * another_number
@@ -85,7 +84,7 @@ Never again violate the `single responsibility principle <https://en.wikipedia.o
8584
**Hate type annotations**!?
8685
No problem!
8786
Types are entirely **optional** with ``attrs``.
88-
Simply assign ``attr.field()`` to the attributes instead of annotating them with types.
87+
Simply assign ``attrs.field()`` to the attributes instead of annotating them with types.
8988

9089
This example uses ``attrs``'s `modern APIs <https://www.attrs.org/en/stable/api.html#next-generation-apis>`_ that have been introduced in version 20.1.0.
9190
The classic APIs (``@attr.s``, ``attr.ib``, ``@attr.attrs``, ``attr.attrib``, and ``attr.dataclass``) will remain indefinitely.

changelog.d/887.breaking.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
``import attrs`` has finally landed!
2+
As of this release, you can finally import ``attrs`` using its proper name.
3+
4+
Not all names from the ``attr`` namespace have been transferred; most notably ``attr.s`` and ``attr.ib`` are missing.
5+
See ``attrs.define`` and ``attrs.field`` if you haven't seen our next-generation APIs yet.
6+
A more elaborate explanation can be found `On The Core API Names <https://www.attrs.org/en/latest/names.html>`_
7+
8+
This feature is at least for one release **provisional**.
9+
We don't *plan* on changing anything, but such a big change is unlikely to go perfectly on the first strike.
10+
11+
The API docs have been mostly updated, but it will be an ongoing effort to change everything to the new APIs.
12+
Please note that we have **not** moved -- or even removed -- anything from ``attr``!
13+
14+
Please do report any bugs or documentation inconsistencies!

conftest.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
from __future__ import absolute_import, division, print_function
22

3-
import sys
4-
53
from hypothesis import HealthCheck, settings
64

7-
from attr._compat import PY310
5+
from attr._compat import PY36, PY310
86

97

108
def pytest_configure(config):
@@ -16,7 +14,7 @@ def pytest_configure(config):
1614

1715

1816
collect_ignore = []
19-
if sys.version_info[:2] < (3, 6):
17+
if not PY36:
2018
collect_ignore.extend(
2119
[
2220
"tests/test_annotations.py",

0 commit comments

Comments
 (0)