Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 23 additions & 17 deletions .github/workflows/lint_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v6
with:
python-version-file: "pyproject.toml"

- name: Install uv
uses: astral-sh/setup-uv@v6
with:
version: "0.8.x"
enable-cache: true
cache-dependency-glob: "uv.lock"

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version-file: "pyproject.toml"

- name: Install dependencies
run: uv sync --all-extras --dev

Expand All @@ -38,21 +38,19 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14-dev"]
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14-dev"]
fail-fast: false

steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v6
with:
version: "0.8.x"
enable-cache: true
cache-dependency-glob: "uv.lock"
- name: Get Non-Hyphenated Python Version
id: get-pyver
run: |
echo "PYVER=$(cut -d '-' -f 1 <<< ${{ matrix.python-version }})" >> $GITHUB_OUTPUT

- name: Set up (release) Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
uses: actions/setup-python@v6
if: "!endsWith(matrix.python-version, '-dev')"
with:
python-version: ${{ matrix.python-version }}
Expand All @@ -63,13 +61,21 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Install uv
uses: astral-sh/setup-uv@v6
with:
version: "0.8.x"
enable-cache: true
cache-dependency-glob: "uv.lock"

- name: Install dependencies
run: |
uv venv
uv pip install tox-gh-actions tox-uv
uv venv --python ${{ steps.get-pyver.outputs.PYVER }}
uv pip install tox-uv

- name: Run tests w/tox
run: uv run tox
run: |
uv run tox -e ${{ steps.get-pyver.outputs.PYVER }}

- name: Cache coverage for ${{ matrix.python-version }}
uses: actions/upload-artifact@v4
Expand All @@ -87,7 +93,7 @@ jobs:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
uses: actions/setup-python@v6
with:
python-version-file: "pyproject.toml"

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pypi_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ jobs:
cache-dependency-glob: "uv.lock"

- name: Set up Python
uses: actions/setup-python@v5
uses: actions/setup-python@v6
with:
python-version-file: "pyproject.toml"

- name: Build package
run: uv build

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1.10
uses: pypa/gh-action-pypi-publish@release/v1.13
with:
print-hash: true

Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ repos:
- id: isort
name: isort
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
rev: v6.0.0
hooks:
- id: check-merge-conflict
- id: check-toml
Expand All @@ -27,7 +27,7 @@ repos:
- id: python-check-blanket-type-ignore
exclude: "test_type_ignore.py"
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.12.7
rev: v0.12.12
hooks:
- id: ruff-check
- repo: local
Expand Down
38 changes: 38 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Contributing
## Python Version Support
A best attempt is made to support Python versions until they reach EOL, after which support will be formally dropped by the next minor or major release of this package, whichever arrives first. The status of Python versions can be found [here](https://devguide.python.org/versions/).

## Development Environment

Development of this project is done using the supported Python version most recently released. Note that tests are run against all supported versions of Python; see: [Testing & Coverage](#testing--coverage) for additional information.

This project uses [uv](https://docs.astral.sh/uv) to manage dependencies. With your fork cloned to your local machine, you can install the project and its dependencies to create a development environment using:

```text
$ uv venv
$ uv sync --all-extras --dev
```

A [`pre-commit`](https://pre-commit.com) configuration is also provided to create a pre-commit hook so linting errors aren't committed:

```text
$ pre-commit install
```

[`mypy`](https://mypy-lang.org/) is also used by this project to provide static type checking. It can be invoked using:

```text
$ mypy .
```

Note that `mypy` is not included as a pre-commit hook.

## Testing & Coverage

A [pytest](https://docs.pytest.org/en/latest/) suite is provided, with coverage reporting from [`pytest-cov`](https://github.com/pytest-dev/pytest-cov). A [`tox`](https://github.com/tox-dev/tox/) configuration is provided to test across all supported versions of Python. Testing will be skipped locally for Python versions that cannot be found; all supported versions are tested in CI.

```text
$ tox
```

Details on missing coverage, including in the test suite, is provided in the report to allow the user to generate additional tests for full coverage. Full code coverage is expected for the majority of code contributed to this project. Some exceptions are expected, primarily around code whose functionality relies on either user input or the presence of external drives; these interactions are currently not mocked, though this may change in the future.
28 changes: 0 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,31 +206,3 @@ Support is only provided for the following patterns:
* `import typing as <alias>; foo: <alias>.Any`

Nested dynamic types (e.g. `typing.Tuple[typing.Any]`) and redefinition (e.g. `from typing import Any as Foo`) will not be identified.

## Contributing
### Python Version Support
A best attempt is made to support Python versions until they reach EOL, after which support will be formally dropped by the next minor or major release of this package, whichever arrives first. The status of Python versions can be found [here](https://devguide.python.org/versions/).

### Development Environment
This project uses [Poetry](https://python-poetry.org/) to manage dependencies. With your fork cloned to your local machine, you can install the project and its dependencies to create a development environment using:

```bash
$ poetry install
```

Note: An editable installation of `flake8-annotations` in the developer environment is required in order for the plugin to be registered for Flake8. By default, Poetry includes an editable install of the project itself when `poetry install` is invoked.

A [pre-commit](https://pre-commit.com) configuration is also provided to create a pre-commit hook so linting errors aren't committed:

```bash
$ pre-commit install
```

### Testing & Coverage
A [pytest](https://docs.pytest.org/en/latest/) suite is provided, with coverage reporting from [pytest-cov](https://github.com/pytest-dev/pytest-cov). A [tox](https://github.com/tox-dev/tox/) configuration is provided to test across all supported versions of Python. Testing will be skipped for Python versions that cannot be found.

```bash
$ tox
```

Details on missing coverage, including in the test suite, is provided in the report to allow the user to generate additional tests for full coverage.
7 changes: 3 additions & 4 deletions flake8_annotations/ast_walker.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

import ast
import typing as t

from attrs import define
from dataclasses import dataclass

from flake8_annotations.enums import AnnotationType, ClassDecoratorType, FunctionType

Expand All @@ -16,7 +15,7 @@
AST_ARG_TYPES: t.Tuple[str, ...] = ("posonlyargs", "args", "vararg", "kwonlyargs", "kwarg")


@define(slots=True)
@dataclass(slots=True)
class Argument:
"""Represent a function argument & its metadata."""

Expand Down Expand Up @@ -74,7 +73,7 @@ def _is_annotated_any(arg_expr: ast.expr) -> bool:
return False


@define(slots=True)
@dataclass(slots=True)
class Function:
"""
Represent a function and its relevant metadata.
Expand Down
4 changes: 1 addition & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ classifiers = [
"Development Status :: 6 - Mature",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
Expand All @@ -29,9 +28,8 @@ classifiers = [
"Typing :: Typed",
]

requires-python = ">=3.9"
requires-python = ">=3.10"
dependencies = [
"attrs~=25.0",
"flake8>=5.0",
]

Expand Down
15 changes: 3 additions & 12 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ exclude_lines =
if TYPE_CHECKING:

[tox]
envlist = clean,py{39,310,311,312,313,314},cog
envlist = clean,py{3.10,3.11,3.12,3.13,3.14},cog
skip_missing_interpreters = True
minversion = 4.0.0
isolated_build = True
requires =
tox >= 4.0

[testenv]
commands = python -m pytest
Expand All @@ -38,14 +39,4 @@ commands = coverage erase
commands = cog -r README.md
deps =
cogapp
attrs
flake8

[gh-actions] # For tox GHA
python =
3.9: py39
3.10: py310
3.11: py311
3.12: py312
3.13: py313
3.14: py314
Loading