Skip to content

Commit e001eb0

Browse files
authored
Move to hatch-vcs for versioning (#422)
This means there's one less thing to do manually when cutting a new release. Rather than us manually updating the `__version__` attribute at the top of the `pyi.py` file, `hatch-vcs` looks at the git tag to determine the version that should be added to the metadata when building a wheel.
1 parent 56fc496 commit e001eb0

File tree

4 files changed

+13
-8
lines changed

4 files changed

+13
-8
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Change Log
22

3+
## Unreleased
4+
5+
* The undocumented `pyi.__version__` and `pyi.PyiTreeChecker.version`
6+
attributes has been removed. Use `flake8 --version` from the command line, or
7+
`importlib.metadata.version("flake8_pyi")` at runtime, to determine the
8+
version of `flake8-pyi` installed at runtime.
9+
310
## 23.10.0
411

512
* Introduce Y090, which warns if you have an annotation such as `tuple[int]` or

CONTRIBUTING.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ release in January 2022 should be called 22.1.0, followed by 22.1.1.
5151

5252
Releasing a new version is easy:
5353

54-
- Make a PR that updates the version header in `CHANGELOG.md`
55-
and the `__version__` attribute in `pyi.py`.
54+
- Make a PR that updates the version header in `CHANGELOG.md`.
5655
- Merge the PR and wait for tests to complete.
5756
- Draft a release using the GitHub UI. The tag name should be
5857
identical to the version (e.g., `22.1.0`) and the release notes

pyi.py

-4
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ def unparse(node: ast.AST) -> str:
3737
# and mypy thinks typing_extensions is part of the stdlib.
3838
from typing_extensions import Literal, TypeAlias, TypeGuard
3939

40-
__version__ = "23.10.0"
41-
4240
LOG = logging.getLogger("flake8.pyi")
4341

4442
if sys.version_info >= (3, 12):
@@ -2005,8 +2003,6 @@ def _check_for_type_comments(lines: list[str]) -> Iterator[Error]:
20052003
@dataclass
20062004
class PyiTreeChecker:
20072005
name: ClassVar[str] = "flake8-pyi"
2008-
version: ClassVar[str] = __version__
2009-
20102006
tree: ast.Module
20112007
lines: list[str]
20122008
filename: str = "(none)"

pyproject.toml

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[build-system]
2-
requires = ["hatchling"]
2+
requires = ["hatchling", "hatch-vcs"]
33
build-backend = "hatchling.build"
44

55
[project]
@@ -74,7 +74,10 @@ dev = [
7474
"flake8.extension" = {Y0 = "pyi:PyiTreeChecker"}
7575

7676
[tool.hatch.version]
77-
path = "pyi.py"
77+
source = "vcs"
78+
79+
[tool.hatch.version.raw-options]
80+
local_scheme = "no-local-version"
7881

7982
[tool.isort]
8083
profile = "black"

0 commit comments

Comments
 (0)