Commit Graph

1385 Commits

Author SHA1 Message Date
Hynek Schlawack 9204fd925e
docs: avoid link artifacts 2023-12-29 09:38:33 +01:00
diabolo-dan 597c3a8adb
Add support for cached_properties to slotted attrs classes. (#1200)
* Add support for cached_properties to slotted attrs classes.

* Remove locking from implementation

* Add test for multiple cached properties and fix bug

* Add changelog file

* Document slotted cached properties

* Add cached_property hypothesis check.

* Only run cached_property imports on python 3.8+

* Use cached _obj_setattr instead of `object.__setattr__`

* Correctly resolve mro for __getattr__ in cached properties

* Use _get_annotations rather than branching on class dict entry

* Optimise __getattr__ code by front loading branching, and injecting locasl variables

* Remove unnecessary `__attrs_original_getattr__` from class dictionary.

---------

Co-authored-by: Hynek Schlawack <hs@ox.cx>
2023-12-08 18:24:25 +00:00
Çağlar Kutlu 01413df3db
Fix for a tiny typo in `_MinLengthValidator` (#1209)
* tiny typo fix for min length validator's error string

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-11-30 05:14:07 +00:00
Hynek Schlawack 0d1be891df
Build docs on 3.12 2023-11-28 13:26:27 +01:00
Aaron Pham 1fcd29f864
Add optional namespace arguments for `make_class` (#1203)
* feat(make_class): add optional namespace arguments to pass through to
`make_class`

Signed-off-by: Aaron <29749331+aarnphm@users.noreply.github.com>

* chore: add changelog

Signed-off-by: Aaron <29749331+aarnphm@users.noreply.github.com>

* Rename `namespaces` to `class_body`

Signed-off-by: Aaron <29749331+aarnphm@users.noreply.github.com>

* Fix versionchanged for correct features

Signed-off-by: Aaron <29749331+aarnphm@users.noreply.github.com>

* Correctly name test case

Signed-off-by: Aaron <29749331+aarnphm@users.noreply.github.com>

* Update changelog

Signed-off-by: Aaron <29749331+aarnphm@users.noreply.github.com>

* Adjust changelog

---------

Signed-off-by: Aaron <29749331+aarnphm@users.noreply.github.com>
Co-authored-by: Hynek Schlawack <hs@ox.cx>
2023-11-28 12:05:46 +00:00
Hynek Schlawack d40d9f3c97
Unbreak docs frontpage 2023-11-23 08:33:37 +01:00
Hynek Schlawack c800d58f42
docs: typo 2023-11-23 08:29:37 +01:00
Hynek Schlawack a3a7b76b5b
pre-commit update 2023-11-23 08:28:46 +01:00
Hynek Schlawack bf357d6e67
Let's stand out 2023-11-23 08:28:31 +01:00
Hynek Schlawack 53d9d07357
All good things come to an end 2023-11-20 09:24:17 +01:00
Eugene Toder 079954ef40
Remove work-arounds for setting cell_contents (#1201)
* Remove work-arounds for setting cell_contents

Simple assignment to cell_contents works starting from Python 3.7[1].
This is also the minimum supported version of Python according to
pyproject.toml. It follows that we don't need complex work-arounds that
were needed in the past.

Also tested on pypy 3.8.

[1] https://bugs.python.org/issue30486

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Hynek Schlawack <hs@ox.cx>
2023-11-11 10:54:24 +00:00
Eugene Toder ea1037cc14
Fix mypy and pyright tests in CI (#1202)
Some error messages changed in mypy 1.7.0 and pyright 1.1.335.

Also, test_mypy sometimes fails with xdist (-n auto). A failure I can
reliably reproduce locally is due to changes in type variables numbering.
There may be other issues.
2023-11-11 10:45:04 +00:00
pre-commit-ci[bot] 1955f72507
[pre-commit.ci] pre-commit autoupdate (#1199)
updates:
- [github.com/astral-sh/ruff-pre-commit: v0.1.3 → v0.1.4](https://github.com/astral-sh/ruff-pre-commit/compare/v0.1.3...v0.1.4)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-11-07 05:44:17 +00:00
Hynek Schlawack 671c53c96f
Avoid paragraphs in checklist
They render weird.
2023-11-01 08:37:41 +01:00
Hynek Schlawack 77172be386
Use Python 3.12 in dev (#1198) 2023-11-01 07:38:39 +01:00
Hynek Schlawack 52c1cd97d7
Update contributing guide (#1196) 2023-10-30 14:57:07 +00:00
Sviatoslav Sydorenko 996672df79
Enable testing merge queues @ GitHub Actions CI/CD (#1195)
This allows org-hosted projects to start enabling merge queues in the
repository settings. With that, GitHub would trigger a separate event
against a merge commit derived from merging several pull requests with
the target branch.

Co-authored-by: Hynek Schlawack <hs@ox.cx>
2023-10-27 10:58:51 +02:00
Hynek Schlawack ede7e5c622
pre-commit autoupdate 2023-10-27 09:47:38 +02:00
Hynek Schlawack c849440ac9
Add more cross-references 2023-10-18 08:39:24 +02:00
Hynek Schlawack 669b78a3fe
docs: explain how we compare (#1192) 2023-10-18 08:14:14 +02:00
Tin Tvrtković fb97252186
Bump mypy, fix tests (#1190)
* Bump mypy, fix tests

* Skip Mypy on 3.7

* Maybe?

* Maybe again?

* Fix old school tuple

* Fix test
2023-10-17 05:48:35 +02:00
Hynek Schlawack bd443b0191
doc: update statement in examples 2023-10-09 15:13:17 +02:00
Hynek Schlawack 5f1d588a66
doc: invert sentence on setattr logic in NG
Even I missed it.
2023-10-09 14:24:30 +02:00
pre-commit-ci[bot] 67e4ff273a
[pre-commit.ci] pre-commit autoupdate (#1189) 2023-10-03 09:08:44 +02:00
dependabot[bot] 9719254054
Bump actions/checkout from 3 to 4 (#1188)
Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-01 07:45:12 +02:00
Hynek Schlawack 1046c75480
Monkeypatching is software bankruptcy 2023-09-29 08:57:03 +02:00
Victor Song c2824ac30f
Pass args from `__init__` to `__attrs_pre_init__` if requested (#1187)
* Pass args from `__init__` to `__attrs_pre_init__` if requested

Detect if `__attrs_pre_init__` has arguments besides `self`
using `inspect.signature`. If so, pass `__attrs_pre_init__`
the same arguments that `__init__` (or `__attrs_init__`)
expects.

* Add changelog entry for `__attrs_pre_init__` args changes

* Don't use monkeypatch in new code

* Clarify docs

* Missed one monkeypatching

---------

Co-authored-by: Hynek Schlawack <hs@ox.cx>
2023-09-29 08:47:51 +02:00
InSync 46a03dcef6
Fix typo in src/attr/_next_gen.py::define's docstring (#1184)
Fix typo

"suprising" -> "surprising"
2023-09-19 07:52:51 +02:00
Hynek Schlawack 06b1bb4141
Unpin Sphinx 2023-09-08 16:29:45 +02:00
Hynek Schlawack b597ed4821
Interrogate: omit covered files 2023-09-08 09:02:46 +02:00
Hynek Schlawack f9869b35ef
Furo errors out on non-HTML builds 2023-09-08 09:02:25 +02:00
pre-commit-ci[bot] 0a44fb51c9
[pre-commit.ci] pre-commit autoupdate (#1181)
updates:
- [github.com/astral-sh/ruff-pre-commit: v0.0.285 → v0.0.287](https://github.com/astral-sh/ruff-pre-commit/compare/v0.0.285...v0.0.287)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-09-05 07:12:35 +02:00
Hugo van Kemenade 336ea8b691
CI: Only attempt publish for upstream (#1179)
Only attempt publish for upstream

Co-authored-by: Hynek Schlawack <hs@ox.cx>
2023-08-20 10:08:07 +00:00
Hynek Schlawack a5cbd51fd9
Tighten linting (#1175)
* Tighten linting

* Consistency

* Simplify config

* Simplify
2023-08-20 12:03:53 +02:00
Hynek Schlawack 5bdd20d52a
Remove more stray changes 2023-08-17 09:34:29 +02:00
Hynek Schlawack 985ce767ba
Run Mypy checks locally, too (#1177) 2023-08-17 09:33:55 +02:00
Hynek Schlawack 73374ba65e
Remove spurious changes 2023-08-17 09:23:41 +02:00
Hynek Schlawack 16dfa9f713
Stop using nodeenv (#1178)
Constant downloading of Node & Pyright is flaky and a waste of resources.
2023-08-17 09:20:45 +02:00
Hynek Schlawack 8514e22bb8
Pin sphinx until furo supports it 2023-08-17 06:21:57 +02:00
Why-not-now 940dd1fdbb
Update examples.md (#1163)
* Update examples.md

Changing order type annotations to fit code
Added attrs.define implementation to slots category

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update docs/examples.md

Co-authored-by: Hynek Schlawack <hs@ox.cx>

* Update docs/examples.md

Co-authored-by: Hynek Schlawack <hs@ox.cx>

* revert test_annotations.py

* Revert test_annotations.py

removed space

---------

Co-authored-by: Hynek Schlawack <hs@ox.cx>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-08-17 05:57:43 +02:00
Hynek Schlawack d538cba50c
We've been testing on 3.12 for a while 2023-08-16 06:03:13 +02:00
Hynek Schlawack 6539cede5c
CodeQL is slow and pointless 2023-08-16 05:57:00 +02:00
Hynek Schlawack 27874f6f17
Avoid yesqa weirdness 2023-08-15 10:10:08 +02:00
Hynek Schlawack 1e751bab13
Add meta section 2023-08-15 09:51:08 +02:00
Hynek Schlawack cceb2d1104
Spread the gospel of -I 2023-08-15 09:48:27 +02:00
Hynek Schlawack 358a83636a
Its watching, not serving 2023-08-15 09:47:24 +02:00
Hynek Schlawack c824bbe103
Allow subclassing of AttrsInstance and Protocol at once (#1172) 2023-08-06 21:33:03 +02:00
pre-commit-ci[bot] 8f4e7e921b
[pre-commit.ci] pre-commit autoupdate (#1168)
updates:
- [github.com/asottile/pyupgrade: v3.9.0 → v3.10.1](https://github.com/asottile/pyupgrade/compare/v3.9.0...v3.10.1)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-08-01 08:41:24 +02:00
Hynek Schlawack 7f161029b4
pre-commit autoupdate 2023-07-29 21:50:36 +02:00
Vitaliy Yelnik 0bf0678a22
Fix TypeError for `asdict(<class with namedtuple>, retain_collection_types=True)` (#1165)
* Fix TypeError for asdict with namedtuples and retain_collection_types=True

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Add news fragment in `changelog.d`

* fix pre-commit interrogate checker

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix flake8 issue

* also fixed `astuple`

* Add `_is_namedtuple` function

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fix SyntaxError for python 3.7

* use `issubclass(..., tuple)`

* use issubclass(cf, tuple) if case of TypeError

* pragma: no cover

* Get rid of the `# no cover`

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* simplify a bit

* Update tests/test_funcs.py

* Update tests/test_funcs.py

* Update tests/test_funcs.py

* Update tests/test_funcs.py

* Update tests/test_funcs.py

* Update tests/test_funcs.py

* Update tests/test_funcs.py

* Update tests/test_funcs.py

* Update changelog.d/1165.change.md

* Escape patterns

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Hynek Schlawack <hs@ox.cx>
2023-07-29 21:31:36 +02:00