Skip to content

Commit

Permalink
Merge branch 'main' into accept-str-for-excludes-and-includes
Browse files Browse the repository at this point in the history
  • Loading branch information
hynek committed Apr 3, 2023
2 parents f609858 + f04fa4e commit c30f382
Show file tree
Hide file tree
Showing 30 changed files with 284 additions and 165 deletions.
53 changes: 45 additions & 8 deletions .github/CONTRIBUTING.md
Expand Up @@ -43,26 +43,40 @@ 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/).
First [fork](https://github.com/python-attrs/attrs/fork) the repository on GitHub.

Next, get an up-to-date checkout of the *attrs* repository:
Clone the fork to your computer:

```console
$ git clone git@github.com:python-attrs/attrs.git
$ git clone git@github.com:<your-username>/attrs.git
```

or if you prefer to use *Git* via `https`:
Or if you prefer to use Git via HTTPS:

```console
$ git clone https://github.com/python-attrs/attrs.git
$ git clone https://github.com/<your-username>/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:
Then add the *attrs* repository as *upstream* remote:

```console
$ git remote add -t main -m main --tags upstream https://github.com/python-attrs/attrs.git
```

The next step is to sync the upstream repository with your local copy:

```console
$ git fetch upstream
```

This is important to obtain eventually missing tags, which are needed to install the development version later on.
See [#1104](https://github.com/python-attrs/attrs/issues/1104) for more information.

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

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

Expand All @@ -84,6 +98,29 @@ $ make html

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

To file a pull request, create a new branch on top of the upstream repository:

```console
$ git fetch --all
$ git checkout -b my_topical_branch upstream/main
```

Make your changes, push them to your fork (the remote *origin*):

```console
$ git push -u origin
```

and publish the PR in GitHub's web interface!

Before starting to work on your next pull request, run the following command to sync your local repository with the remotes:

```console
$ git fetch --all
$ git checkout main
$ git merge
```

---

To avoid committing code that violates our style guide, we strongly advise you to install [*pre-commit*] and its hooks:
Expand Down
2 changes: 0 additions & 2 deletions .github/FUNDING.yml
@@ -1,5 +1,3 @@
---

github: hynek
ko_fi: the_hynek
tidelift: "pypi/attrs"
11 changes: 3 additions & 8 deletions .github/workflows/build-docset.yml
Expand Up @@ -10,24 +10,19 @@ env:
PIP_DISABLE_PIP_VERSION_CHECK: 1
PIP_NO_PYTHON_VERSION_WARNING: 1

permissions: # added using https://github.com/step-security/secure-workflows
permissions:
contents: read

jobs:
docset:
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@v2
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs

- uses: actions/checkout@v3
with:
fetch-depth: 0 # get correct version once we switch to hatch-vcs
fetch-depth: 0
- uses: actions/setup-python@v4
with:
python-version: "3.11"
python-version: "3.x"

- run: pip install tox

Expand Down
71 changes: 7 additions & 64 deletions .github/workflows/ci.yml
Expand Up @@ -14,16 +14,17 @@ env:
TOX_TESTENV_PASSENV: FORCE_COLOR
PIP_DISABLE_PIP_VERSION_CHECK: "1"
PIP_NO_PYTHON_VERSION_WARNING: "1"
# Keep in sync with .pre-commit-config.yaml/default_language_version/python.
PYTHON_LATEST: "3.11"
# avoid warnings about shallow checkout, but also make sure pytest accepts us.
# Avoid warnings about shallow checkout, but also make sure pytest accepts us.
SETUPTOOLS_SCM_PRETEND_VERSION: "99.9.9"

permissions:
contents: read

jobs:
tests:
name: tests on ${{ matrix.python-version }}
name: Tests on ${{ matrix.python-version }}
runs-on: ubuntu-latest

strategy:
Expand All @@ -43,20 +44,11 @@ jobs:
${{ contains(matrix.python-version, '~') && true || false }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@v2
with:
egress-policy: block
allowed-endpoints: >
api.github.com:443
files.pythonhosted.org:443
github.com:443
objects.githubusercontent.com:443
pypi.org:443
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- run: python -Im pip install --upgrade wheel tox

- name: Determine Python version for tox
run: |
Expand All @@ -74,7 +66,6 @@ jobs:
echo TOX_PYTHON=$V >>$GITHUB_ENV
- run: python -Im pip install --upgrade wheel tox
- run: python -Im tox run -f ${{ env.TOX_PYTHON }}

- name: Upload coverage data
Expand All @@ -89,16 +80,6 @@ jobs:
needs: tests

steps:
- name: Harden Runner
uses: step-security/harden-runner@v2
with:
egress-policy: block
allowed-endpoints: >
files.pythonhosted.org:443
github.com:443
pypi.org:443
api.github.com:443
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
Expand Down Expand Up @@ -129,27 +110,17 @@ jobs:
name: Build docs & run doctests
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@v2
with:
egress-policy: block
allowed-endpoints: >
docs.python.org:443
files.pythonhosted.org:443
github.com:443
pypi.org:443
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
# Keep in sync with tox/docs and .readthedocs.yaml.
python-version: "3.10"
python-version: "3.11"

- run: python -Im pip install --upgrade wheel tox
- run: python -Im tox -e docs,changelog

mypy:
name: mypy on ${{ matrix.python-version }}
name: Mypy on ${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand All @@ -174,18 +145,6 @@ jobs:
name: Check types using pyright
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@v2
with:
egress-policy: block
allowed-endpoints: >
files.pythonhosted.org:443
github.com:443
nodejs.org:443
pypi.org:443
registry.npmjs.org:443
api.github.com:443
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
Expand All @@ -202,22 +161,13 @@ jobs:
os: [ubuntu-latest, windows-latest]

steps:
- name: Harden Runner
uses: step-security/harden-runner@v2
with:
disable-sudo: true
egress-policy: block
allowed-endpoints: >
files.pythonhosted.org:443
github.com:443
pypi.org:443
api.github.com:443
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{env.PYTHON_LATEST}}
- run: python -Im pip install -e .[dev]
- run: python -Ic 'import attr; print(attr.__version__)'
- run: python -Ic 'import attrs; print(attrs.__version__)'

# Ensure everything required is passing for branch protection.
required-checks-pass:
Expand All @@ -233,13 +183,6 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Harden Runner
uses: step-security/harden-runner@v2
with:
disable-sudo: true
egress-policy: block
allowed-endpoints: >
api.github.com:443
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
Expand Down
12 changes: 0 additions & 12 deletions .github/workflows/codeql-analysis.yml
Expand Up @@ -27,18 +27,6 @@ jobs:
language: ["python"]

steps:
- name: Harden Runner
uses: step-security/harden-runner@v2
with:
egress-policy: block
allowed-endpoints: >
api.github.com:443
bootstrap.pypa.io:443
files.pythonhosted.org:443
github.com:443
pypi.org:443
uploads.github.com:443
- name: Checkout repository
uses: actions/checkout@v3

Expand Down
25 changes: 1 addition & 24 deletions .github/workflows/pypi-package.yml
Expand Up @@ -22,15 +22,6 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: step-security/harden-runner@v2
with:
disable-sudo: true
egress-policy: block
allowed-endpoints: >
files.pythonhosted.org:443
github.com:443
pypi.org:443
- uses: actions/checkout@v3
with:
fetch-depth: 0
Expand All @@ -46,13 +37,6 @@ jobs:
needs: build-package

steps:
- uses: step-security/harden-runner@v2
with:
disable-sudo: true
egress-policy: block
allowed-endpoints: >
test.pypi.org:443
- name: Download packages built by build-and-inspect-python-package
uses: actions/download-artifact@v3
with:
Expand All @@ -63,7 +47,7 @@ jobs:
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
repository-url: https://test.pypi.org/legacy/

# Upload to real PyPI on GitHub Releases.
release-pypi:
Expand All @@ -74,13 +58,6 @@ jobs:
needs: build-package

steps:
- uses: step-security/harden-runner@v2
with:
disable-sudo: true
egress-policy: block
allowed-endpoints: >
upload.pypi.org:443
- name: Download packages built by build-and-inspect-python-package
uses: actions/download-artifact@v3
with:
Expand Down
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Expand Up @@ -3,6 +3,7 @@ ci:
autoupdate_schedule: monthly

default_language_version:
# Keep in sync with ci.yml/PYTHON_LATEST
python: python3.11

repos:
Expand Down
2 changes: 1 addition & 1 deletion .readthedocs.yaml
Expand Up @@ -6,7 +6,7 @@ build:
os: ubuntu-20.04
tools:
# Keep version in sync with tox.ini/docs and ci.yml/docs.
python: "3.10"
python: "3.11"

python:
install:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -143,7 +143,7 @@ For more details, please refer to our [comparison page](https://www.attrs.org/en
- [**Third-party Extensions**](https://github.com/python-attrs/attrs/wiki/Extensions-to-attrs)
- **License**: [MIT](https://www.attrs.org/en/latest/license.html)
- **Get Help**: please use the `python-attrs` tag on [StackOverflow](https://stackoverflow.com/questions/tagged/python-attrs)
- **Supported Python Versions**: 3.6 and later
- **Supported Python Versions**: 3.7 and later


### *attrs* for Enterprise
Expand Down
1 change: 1 addition & 0 deletions changelog.d/1079.change.md
@@ -0,0 +1 @@
`attrs.has()` and `attrs.fields()` now handle generic classes correctly.
1 change: 1 addition & 0 deletions changelog.d/1092.change.md
@@ -0,0 +1 @@
Fix slots class cellvar updating closure in CPython 3.8+ even when `__code__` introspection is unavailable.
1 change: 1 addition & 0 deletions changelog.d/1099.change.md
@@ -0,0 +1 @@
`attrs.resolve_types()` can now pass `include_extras` to `typing.get_type_hints()` on Python 3.9+, and does so by default.
1 change: 1 addition & 0 deletions changelog.d/1105.change.md
@@ -0,0 +1 @@
Added instructions for pull request workflow to `CONTRIBUTING.md`.
3 changes: 3 additions & 0 deletions changelog.d/1107.change.md
@@ -0,0 +1,3 @@
Added *type* parameter to `attrs.field()` function for use with `attrs.make_class().

Please note that type checkers ignore type metadata passed into `make_class()`, but it can be useful if you're wrapping _attrs_.
1 change: 1 addition & 0 deletions changelog.d/993.breaking.md
@@ -0,0 +1 @@
Python 3.6 has been dropped and packaging switched to static package data using [Hatch](https://hatch.pypa.io/latest/).

0 comments on commit c30f382

Please sign in to comment.