Skip to content

Commit

Permalink
Merge branch 'main' into attrib_alias
Browse files Browse the repository at this point in the history
  • Loading branch information
hynek committed Aug 10, 2022
2 parents 40a5161 + 6151683 commit b12c230
Show file tree
Hide file tree
Showing 58 changed files with 424 additions and 522 deletions.
128 changes: 64 additions & 64 deletions .github/CONTRIBUTING.md
Expand Up @@ -34,7 +34,67 @@ The official tag is `python-attrs` and helping out in support frees us up to imp
If you have problems to test something, open anyway and ask for advice.
In some situations, we may agree to add an `# pragma: no cover`.
- Once you've addressed review feedback, make sure to bump the pull request with a short note, so we know you're done.
- Don’t break backwards compatibility.
- Don’t break backwards-compatibility.


## Local Development Environment

You can (and should) run our test suite using [*tox*].
However, you’ll probably want a more traditional environment as well.
We highly recommend to develop using the latest Python release because we try to take advantage of modern features whenever possible.

First create a [virtual environment](https://virtualenv.pypa.io/) so you don't break your system-wide Python installation.
It’s out of scope for this document to list all the ways to manage virtual environments in Python, but if you don’t already have a pet way, take some time to look at tools like [*direnv*](https://hynek.me/til/python-project-local-venvs/), [*virtualfish*](https://virtualfish.readthedocs.io/), and [*virtualenvwrapper*](https://virtualenvwrapper.readthedocs.io/).

Next, get an up-to-date checkout of the `attrs` repository:

```console
$ git clone git@github.com:python-attrs/attrs.git
```

or if you prefer to use git via `https`:

```console
$ git clone https://github.com/python-attrs/attrs.git
```

Change into the newly created directory and **after activating your virtual environment** install an editable version of `attrs` along with its tests and docs requirements:

```console
$ cd attrs
$ python -m pip install --upgrade pip setuptools # PLEASE don't skip this step
$ python -m pip install -e '.[dev]'
```

At this point,

```console
$ python -m pytest
```

should work and pass, as should:

```console
$ cd docs
$ make html
```

The built documentation can then be found in `docs/_build/html/`.

To avoid committing code that violates our style guide, we strongly advise you to install [*pre-commit*] [^dev] hooks:

```console
$ pre-commit install
```

You can also run them anytime (as our *tox* does) using:

```console
$ pre-commit run --all-files
```

[^dev]: *pre-commit* should have been installed into your virtualenv automatically when you ran `pip install -e '.[dev]'` above.
If *pre-commit* is missing, your probably need to run `pip install -e '.[dev]'` again.


## Code
Expand All @@ -54,7 +114,7 @@ The official tag is `python-attrs` and helping out in support frees us up to imp
```
- If you add or change public APIs, tag the docstring using `.. versionadded:: 16.0.0 WHAT` or `.. versionchanged:: 16.2.0 WHAT`.
- We use [*isort*](https://github.com/PyCQA/isort) to sort our imports, and we use [*Black*](https://github.com/psf/black) with line length of 79 characters to format our code.
As long as you run our full [*tox*] suite before committing, or install our [*pre-commit*] hooks (ideally you'll do both – see [*Local Development Environment*](#local-development-environment) below), you won't have to spend any time on formatting your code at all.
As long as you run our full [*tox*] suite before committing, or install our [*pre-commit*] hooks (ideally you'll do both – see [*Local Development Environment*](#local-development-environment) above), you won't have to spend any time on formatting your code at all.
If you don't, [CI] will catch it for you – but that seems like a waste of your time!


Expand All @@ -81,7 +141,7 @@ The official tag is `python-attrs` and helping out in support frees us up to imp

## Documentation

- Use [semantic newlines] in [*reStructuredText*] files (files ending in `.rst`):
- Use [semantic newlines] in [*reStructuredText*] and [*Markdown*](https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax) files (files ending in `.rst` and `.md`):

```rst
This is a sentence.
Expand Down Expand Up @@ -152,66 +212,6 @@ or:
``tox -e changelog`` will render the current changelog to the terminal if you have any doubts.


## Local Development Environment

You can (and should) run our test suite using [*tox*].
However, you’ll probably want a more traditional environment as well.
We highly recommend to develop using the latest Python release because we try to take advantage of modern features whenever possible.

First create a [virtual environment](https://virtualenv.pypa.io/) so you don't break your system-wide Python installation.
It’s out of scope for this document to list all the ways to manage virtual environments in Python, but if you don’t already have a pet way, take some time to look at tools like [*direnv*](https://hynek.me/til/python-project-local-venvs/), [*virtualfish*](https://virtualfish.readthedocs.io/), and [*virtualenvwrapper*](https://virtualenvwrapper.readthedocs.io/).

Next, get an up to date checkout of the `attrs` repository:

```console
$ git clone git@github.com:python-attrs/attrs.git
```

or if you want to use git via `https`:

```console
$ git clone https://github.com/python-attrs/attrs.git
```

Change into the newly created directory and **after activating your virtual environment** install an editable version of `attrs` along with its tests and docs requirements:

```console
$ cd attrs
$ pip install --upgrade pip setuptools # PLEASE don't skip this step
$ pip install -e '.[dev]'
```

At this point,

```console
$ python -m pytest
```

should work and pass, as should:

```console
$ cd docs
$ make html
```

The built documentation can then be found in `docs/_build/html/`.

To avoid committing code that violates our style guide, we strongly advise you to install [*pre-commit*] [^dev] hooks:

```console
$ pre-commit install
```

You can also run them anytime (as our tox does) using:

```console
$ pre-commit run --all-files
```

[^dev]: *pre-commit* should have been installed into your virtualenv automatically when you ran `pip install -e '.[dev]'` above.
If *pre-commit* is missing, your probably need to run `pip install -e '.[dev]'` again.


## Governance

`attrs` is maintained by [team of volunteers](https://github.com/python-attrs) that is always open to new members that share our vision of a fast, lean, and magic-free library that empowers programmers to write better code with less effort.
Expand All @@ -225,6 +225,6 @@ If you'd like to join, just get a pull request merged and ask to be added in the
[CI]: https://github.com/python-attrs/attrs/actions?query=workflow%3ACI
[Hynek Schlawack]: https://hynek.me/about/
[*pre-commit*]: https://pre-commit.com/
[*tox*]: https://https://tox.wiki/
[*tox*]: https://tox.wiki/
[semantic newlines]: https://rhodesmill.org/brandon/2012/one-sentence-per-line/
[*reStructuredText*]: https://www.sphinx-doc.org/en/stable/usage/restructuredtext/basics.html
10 changes: 10 additions & 0 deletions .github/SECURITY.md
@@ -1,2 +1,12 @@
# Security Policy

## Supported Versions

We are following [CalVer](https://calver.org) with generous backwards-compatibility guarantees.
Therefore we only support the latest version.


## Reporting a Vulnerability

To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security).
Tidelift will coordinate the fix and disclosure.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Expand Up @@ -23,7 +23,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.5", "3.6", "3.7", "3.8", "3.9", "3.10", "pypy-3.7", "pypy-3.8"]
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11.0-beta - 3.11", "pypy-3.7", "pypy-3.8"]

steps:
- uses: actions/checkout@v3
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Expand Up @@ -2,12 +2,16 @@
*.pyc
.cache
.coverage*
.direnv
.envrc
.hypothesis
.mypy_cache
.pytest_cache
.tox
.vscode
build
dist
docs/_build/
htmlcov
pip-wheel-metadata
tmp
22 changes: 13 additions & 9 deletions .pre-commit-config.yaml
Expand Up @@ -2,17 +2,20 @@
ci:
autoupdate_schedule: monthly

default_language_version:
python: python3.10 # needed for match

repos:
- repo: https://github.com/psf/black
rev: 22.3.0
rev: 22.6.0
hooks:
- id: black

- repo: https://github.com/asottile/pyupgrade
rev: v2.32.1
rev: v2.37.3
hooks:
- id: pyupgrade
args: [--py3-plus, --keep-percent-format]
args: [--py36-plus, --keep-percent-format]
exclude: "tests/test_slots.py"

- repo: https://github.com/PyCQA/isort
Expand All @@ -21,27 +24,28 @@ repos:
- id: isort
additional_dependencies: [toml]
files: \.py$
language_version: python3.10 # needed for match

- repo: https://github.com/asottile/yesqa
rev: v1.3.0
hooks:
- id: yesqa

- repo: https://github.com/PyCQA/flake8
rev: 4.0.1
rev: 5.0.2
hooks:
- id: flake8
language_version: python3.10

- repo: https://github.com/econchick/interrogate
rev: 1.5.0
hooks:
- id: interrogate
args: [tests]
language_version: python3.10 # needed for match

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.2.0
rev: v4.3.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: debug-statements
language_version: python3.10 # needed for match
- id: check-toml
- id: check-yaml
4 changes: 2 additions & 2 deletions AUTHORS.rst
Expand Up @@ -3,9 +3,9 @@ Credits

``attrs`` is written and maintained by `Hynek Schlawack <https://hynek.me/>`_.

The development is kindly supported by `Variomedia AG <https://www.variomedia.de/>`_.
The development is kindly supported by `Variomedia AG <https://www.variomedia.de/>`_, ``attrs`` `Tidelift subscribers <https://tidelift.com/subscription/pkg/pypi-attrs?utm_source=pypi-attrs&utm_medium=referral&utm_campaign=enterprise&utm_term=repo>`_, and all my amazing `GitHub Sponsors <https://github.com/sponsors/hynek>`_.

A full list of contributors can be found in `GitHub's overview <https://github.com/python-attrs/attrs/graphs/contributors>`_.

It’s the spiritual successor of `characteristic <https://characteristic.readthedocs.io/>`_ and aspires to fix some of it clunkiness and unfortunate decisions.
Both were inspired by Twisted’s `FancyEqMixin <https://twistedmatrix.com/documents/current/api/twisted.python.util.FancyEqMixin.html>`_ but both are implemented using class decorators because `subclassing is bad for you <https://www.youtube.com/watch?v=3MNVP9-hglc>`_, m’kay?
Both were inspired by Twisted’s `FancyEqMixin <https://docs.twisted.org/en/stable/api/twisted.python.util.FancyEqMixin.html>`_ but both are implemented using class decorators because `subclassing is bad for you <https://www.youtube.com/watch?v=3MNVP9-hglc>`_, m’kay?
44 changes: 43 additions & 1 deletion CHANGELOG.rst
Expand Up @@ -28,6 +28,48 @@ Changes for the upcoming release can be found in the `"changelog.d" directory <h

.. towncrier release notes start
22.1.0 (2022-07-28)
-------------------

Backwards-incompatible Changes
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

- Python 2.7 is not supported anymore.

Dealing with Python 2.7 tooling has become too difficult for a volunteer-run project.

We have supported Python 2 more than 2 years after it was officially discontinued and feel that we have paid our dues.
All version up to 21.4.0 from December 2021 remain fully functional, of course.
`#936 <https://github.com/python-attrs/attrs/issues/936>`_
- The deprecated ``cmp`` attribute of ``attrs.Attribute`` has been removed.
This does not affect the *cmp* argument to ``attr.s`` that can be used as a shortcut to set *eq* and *order* at the same time.
`#939 <https://github.com/python-attrs/attrs/issues/939>`_


Changes
^^^^^^^

- Instantiation of frozen slotted classes is now faster.
`#898 <https://github.com/python-attrs/attrs/issues/898>`_
- If an ``eq`` key is defined, it is also used before hashing the attribute.
`#909 <https://github.com/python-attrs/attrs/issues/909>`_
- Added ``attrs.validators.min_len()``.
`#916 <https://github.com/python-attrs/attrs/issues/916>`_
- ``attrs.validators.deep_iterable()``'s *member_validator* argument now also accepts a list of validators and wraps them in an ``attrs.validators.and_()``.
`#925 <https://github.com/python-attrs/attrs/issues/925>`_
- Added missing type stub re-imports for ``attrs.converters`` and ``attrs.filters``.
`#931 <https://github.com/python-attrs/attrs/issues/931>`_
- Added missing stub for ``attr(s).cmp_using()``.
`#949 <https://github.com/python-attrs/attrs/issues/949>`_
- ``attrs.validators._in()``'s ``ValueError`` is not missing the attribute, expected options, and the value it got anymore.
`#951 <https://github.com/python-attrs/attrs/issues/951>`_
- Python 3.11 is now officially supported.
`#969 <https://github.com/python-attrs/attrs/issues/969>`_


----


21.4.0 (2021-12-29)
-------------------

Expand Down Expand Up @@ -940,7 +982,7 @@ Deprecations:
This will remove the confusing error message if you write your own ``__init__`` and forget to initialize some attribute.
Instead you will get a straightforward ``AttributeError``.
In other words: decorated classes will work more like plain Python classes which was always ``attrs``'s goal.
- The serious business aliases ``attr.attributes`` and ``attr.attr`` have been deprecated in favor of ``attr.attrs`` and ``attr.attrib`` which are much more consistent and frankly obvious in hindsight.
- The serious-business aliases ``attr.attributes`` and ``attr.attr`` have been deprecated in favor of ``attr.attrs`` and ``attr.attrib`` which are much more consistent and frankly obvious in hindsight.
They will be purged from documentation immediately but there are no plans to actually remove them.


Expand Down
9 changes: 9 additions & 0 deletions CITATION.cff
@@ -0,0 +1,9 @@
cff-version: 1.2.0
message: If you use this software, please cite it as below.
title: attrs
type: software
authors:
- given-names: Hynek
family-names: Schlawack
email: hs@ox.cx
doi: 10.5281/zenodo.6925130
2 changes: 1 addition & 1 deletion LICENSE
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2015 Hynek Schlawack
Copyright (c) 2015 Hynek Schlawack and the attrs contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion MANIFEST.in
@@ -1,4 +1,4 @@
include LICENSE *.rst *.toml *.yml *.yaml *.ini
include LICENSE *.rst *.toml *.yml *.yaml *.ini CITATION.cff
graft .github

# Stubs
Expand Down

0 comments on commit b12c230

Please sign in to comment.