Commit Graph

1586 Commits

Author SHA1 Message Date
Hynek Schlawack 09161fc918
Fix crash when __pre_init__, kw_only, and defaults come together (#1319)
* Fix crash when __pre_init__, kw_only, and defaults come together

Fixes #1284

* Add news fragment

* Improve test
2024-08-03 13:31:53 +02:00
Hynek Schlawack 689a0e6401
Simplify & optimize own attribute detection (#1322) 2024-08-03 13:24:28 +02:00
Hynek Schlawack f7e4e91073
docs: fix typo 2024-08-02 09:32:57 +02:00
Hynek Schlawack 42c954869d
Invert API docs to point from NG to OG (#1316)
* Add disclaimer to attr NS

* Transplant API docs from attr.s to attrs.define

* Transplant API docs from attr.ib to attrs.field

* Remove stale references to attr.ib

* Fix refs

* Link to glossary

* Explain why

* Links from API docs, too

* Link type annotations for good measure
2024-08-02 08:03:14 +02:00
Hynek Schlawack c0ca14c66c
Fix Tidelift URL 2024-08-01 17:27:59 +02:00
dependabot[bot] 2db6e9af95
Bump CodSpeedHQ/action from 2 to 3 (#1318)
Bumps [CodSpeedHQ/action](https://github.com/codspeedhq/action) from 2 to 3.
- [Release notes](https://github.com/codspeedhq/action/releases)
- [Changelog](https://github.com/CodSpeedHQ/action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/codspeedhq/action/compare/v2...v3)

---
updated-dependencies:
- dependency-name: CodSpeedHQ/action
  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>
Co-authored-by: Hynek Schlawack <hs@ox.cx>
2024-08-01 08:13:07 +00:00
Hynek Schlawack 14bad1f56e
ci: run CodeSpeed when it's workflow changes 2024-08-01 08:14:08 +02:00
Hynek Schlawack 1dfd14856b
Limit xdist distribution to files
I get regularly spurious failures in tox in the Mypy tests because of
being able to access certain files. I hope running the file
non-concurently helps here.
2024-08-01 07:05:59 +02:00
Hynek Schlawack b78abadbbf
docs: add glossary entries for field & attribute 2024-08-01 06:43:24 +02:00
Hynek Schlawack a365cdc5fe
More f-strings (#1317) 2024-07-31 13:37:38 +02:00
Hynek Schlawack c24b8ad6f7
Pin breaking Mypy 2024-07-31 13:26:55 +02:00
Hynek Schlawack d82c3f361a
docs 2024-07-31 10:58:09 +02:00
Hynek Schlawack bf8727aed5
More uv + caching (#1315) 2024-07-31 10:26:13 +02:00
Hynek Schlawack 7c6490b6c1
Pin Towncrier (#1314)
See https://github.com/sphinx-contrib/sphinxcontrib-towncrier/issues/92
2024-07-31 10:00:21 +02:00
Hynek Schlawack adf4b61723
ci/tox: print towncrier version 2024-07-31 09:47:10 +02:00
Hynek Schlawack 5eefa5aab1
update ruff 2024-07-31 09:39:44 +02:00
Hynek Schlawack bcda3e17ba
docs: don't assume people use pip anymore 2024-07-31 09:39:28 +02:00
Hynek Schlawack f5683b852b
converters: allow wrapping and passing self and fields (#1267)
* converters: allow wrapping & takes_self

* Add takes field

* Add news fragment

* Refactor name and call creation

* Make argument names more idiomatic

* Add missing hints

* Make 3-arg converters zero-overhead at runtime

* Remove unnecessary changes

* More idiomatic name

* Explain method

* Make pickle test more meaningful

* Add unit tests for fmt_converter_call

* Check our eq works too

* Convert Converter docstring to Napoleon

* Fix rebase fubar

* Add ~types~

* Comment out failing mypy tests for now

* Fix mypy tests

* Add warning

* Add narrative docs

* Fix converter overloads, add tests

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

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

---------

Co-authored-by: Tin Tvrtković <tinchester@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-07-28 13:55:24 +00:00
Hynek Schlawack 0f045cd231
More hogoblin 2024-07-26 06:30:17 +02:00
Hynek Schlawack d7db2186df
Feed the hogoblin 2024-07-25 08:08:06 +02:00
Hynek Schlawack 323bd2a2de
Only run CodSpeed if *.py files change
No need to run on .pyi
2024-07-24 12:56:45 +02:00
Hynek Schlawack bce982025f
CI: explicit version for dev env (#1312)
* CI: Be explicit about the venv Python version

* Activate
2024-07-22 07:27:48 +02:00
Hynek Schlawack b8899cfc4f
Simplify dev env testing
Windows is brutally slow and the tools are cross-platform nowadays.
2024-07-22 07:20:44 +02:00
Hynek Schlawack f8fa67a936
Only run CodSpeed whenever code changes (#1311)
* Only run CodSpeed whenever code changes

It's very slow and very computationally expensive.

No point running it on docs typo changes.

* Limit on PRs too
2024-07-22 07:15:44 +02:00
Hynek Schlawack 943976926b
PyPy 3.8 is not supported by upstream anymore
And apparently has some weird bugs.
2024-07-22 05:55:59 +02:00
Hynek Schlawack 01d35a3795
docs: fix typo 2024-07-22 05:49:19 +02:00
Hynek Schlawack 8a8cd91bdf
Switch docstrings to Napoleon style (#1308)
* Switch docstrings to Napoleon style

This makes them much more readable while editing.

c.f. https://www.sphinx-doc.org/en/master/usage/extensions/napoleon.html

* Add example for Raises
2024-07-21 12:06:19 +02:00
Tin Tvrtković a8808a2b3e
Speed up __eq__ (#1310)
* Speed up __eq__

* Changelog, disallow nans in tests

* Fix `eq_key` comparisons

* Rework changlelog

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

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

* Make docs more precise

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-07-21 09:53:35 +00:00
Hynek Schlawack feb7a4d892
Fix typo 2024-07-19 13:02:13 +02:00
Hynek Schlawack 28adb06aaf
Remove hatch run due to unpredictable Python version 2024-07-19 12:56:28 +02:00
Hynek Schlawack 52dfaf00ed
Streamline contributing
Make it less of an incomplete Git tutorial and more GitHub-adjacent.

Also add a Hatch script to just run tests without dealing with venvs.
2024-07-19 12:31:59 +02:00
Hynek Schlawack 88e13dd6ab
Make logos slightly smaller so 4 fit in 1 line
Like on GitHub
2024-07-19 11:24:36 +02:00
Hynek Schlawack 18f7f992b6
Benchmarks aren't discoverable anymore 2024-07-19 11:14:50 +02:00
Hynek Schlawack 6733796c5f
Add nuance to subclassing statements
C.f.
https://stackoverflow.com/questions/78424953/how-to-implement-class-composition/78427868?noredirect=1#comment138293629_78427868
2024-07-19 11:11:48 +02:00
Hynek Schlawack 52893141db
Use relative sponsor links in docs 2024-07-19 11:09:25 +02:00
Hynek Schlawack 5f93a31aff
Switch to build-and-inspect-python-package (#1307)
* Switch to build-and-inspect-python-package

Use the occasion to factor out PyPy jobs which simplifies everthing.

* Only install pytest-codspeed when benchmarking

* No need to build twice on PRs

* No coverage on PyPy

* Still require PyPy to pass

* Actually remove codspeed from tests

* Separate glacial CodSpeed into own workflow

Might switch to on-demand/cron if we don't find a way for it to run
under 5 minutes.

* Get rid of version override

* Add missing needs

* Test should pass without src

* oops

* Make PyPy wheel-only, too

* Clarify

* Explain how the matrix works since everybody steals my stuff
2024-07-19 10:56:10 +02:00
Hynek Schlawack e4bffa0a74
docs 2024-07-18 11:20:39 +02:00
Hynek Schlawack 1fd3af0b94
Write specific benchmarks for CodSpeed (#1306)
* Write specific benchmarks for CodSpeed

* Add frozen benchmark

* Remove instantiation noise

* Put into separate dir like cattrs

* Be consistent
2024-07-18 11:00:27 +02:00
Hynek Schlawack 0a09c1aa2c
Don't run CodSpeed on merge_group events (#1305)
It's not supported.
2024-07-17 14:08:24 +00:00
Hynek Schlawack 3df6017637
Improve sponsor handling (#1304)
* Improve sponsor handling

* Try to use tox

* Use python instead of pip

* Be consistent
2024-07-17 13:27:30 +00:00
Hynek Schlawack 829c2ff15a
docs: improve RTD 2024-07-17 14:14:35 +02:00
Libor Martínek 7c9b31ea7b
Add `attrs.validators.or_` validator (#1303)
* Implement attrs.validators.or_ validator

* Add tests/test_validators.py::TestOr test cases

* Add test for _OrValidator.__repr__ method

* Add description of attrs.validators.or_ to docs/api.rst

* Add changelog entry

* Swap double quotes for single because doctests don't like it

* Rename changelog fragment pointing to incorrect number

* Silence ruff linter warnings

Although good warning in general, in this particular code, they
do not fit here.

* BLE001 Do not catch blind exception: `Exception`
    `validators` usually raise `ValueError` upon their violation.
    However, it's not the only `Exception` they can raise - cf.
    `attrs.validators.not_` - therefore, it is desirable to catch
    them all!
* PERF203 `try`-`except` within a loop incurs performance overhead
    Fair point, but the loop is written in a way to short-circuit,
    ie. it will finish when a first validator is satisfied.
* S112 `try`-`except`-`continue` detected, consider logging the exception
    Not applicable here, we care only if **all** validators raise
    an exception, which is already accomodated for after the `for`
    loop.

* Apply suggestions from code review

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

* Rework example of or_ validator in api/docs.rst

* Update docs/api.rst

---------

Co-authored-by: Hynek Schlawack <hs@ox.cx>
Co-authored-by: Libor <libas.martinek@protonmail.com>
2024-07-17 12:01:41 +00:00
Hynek Schlawack 37ac3ef088
docs: improve why 2024-07-15 16:16:19 +02:00
Hynek Schlawack be3015293c
Work around CodSpeed/cffi 3.13 incompatibility 2024-07-15 15:54:05 +02:00
Hynek Schlawack a518d9ddfe
docs: make more examplar 2024-07-15 11:27:08 +02:00
Hynek Schlawack 8079a35545
Python 3.8 doesn't pass on Mypy anymore 2024-07-15 11:26:57 +02:00
Hynek Schlawack 8e759ce878
docs: better separation of the ToC 2024-07-15 11:26:45 +02:00
Hynek Schlawack 9ebd31c894
update ruff 2024-07-15 11:15:17 +02:00
Hynek Schlawack 08b1b9ccd0
docs: add more terms that ppl might know 2024-07-15 11:00:55 +02:00
Stefan Scherfke edcaf04a4d
make_class(): Add "__annotations_" to generated class (#1285)
* make_class(): Add "__annotations_" to generated class

Fixes: #1271

* Fix PR#

* Flip

---------

Co-authored-by: Hynek Schlawack <hs@ox.cx>
2024-07-13 10:52:46 +00:00