Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to hatchling & pip-tools #22

Merged
merged 5 commits into from
Sep 27, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
56 changes: 26 additions & 30 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11.0-alpha - 3.11']
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11-dev']

runs-on: ubuntu-latest

Expand All @@ -26,27 +26,19 @@ jobs:
- uses: actions/checkout@v3

- name: set up python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- uses: actions/cache@v3
id: cache
with:
path: ${{ env.pythonLocation }}
key: ${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('tests/requirements.txt') }}

- run: pip install -r tests/requirements.txt
if: steps.cache.outputs.cache-hit != 'true'
- run: pip install -r requirements/testing.txt

- run: poetry install
if: steps.cache.outputs.cache-hit != 'true'
- run: pip install .

- run: make test

- run: coverage xml

- uses: codecov/codecov-action@v2.1.0
- uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
env_vars: PYTHON
Expand All @@ -57,23 +49,15 @@ jobs:
steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v2
- uses: actions/setup-python@v4
with:
python-version: '3.10'

- uses: actions/cache@v3
id: cache
with:
path: |
${{ env.pythonLocation }}
.mypy_cache
key: v2-${{ hashFiles('tests/requirements-linting.txt') }}
- run: pip install -r requirements/linting.txt

- run: pip install -r tests/requirements-linting.txt
if: steps.cache.outputs.cache-hit != 'true'

- run: make lint
- run: make mypy
- uses: pre-commit/action@v3.0.0
with:
extra_args: --all-files --verbose

deploy:
needs:
Expand All @@ -86,12 +70,24 @@ jobs:
- uses: actions/checkout@v3

- name: set up python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: '3.10'

- run: pip install poetry==1.2.0a2 poetry-version-plugin
- run: pip install -U twine build

- name: check GITHUB_REF matches package version
uses: samuelcolvin/check-python-version@v3
with:
version_file_path: annotated_types/__init__.py

- name: build
run: python -m build

- run: twine check dist/*

- run: poetry publish --build
- name: upload to pypi
run: twine upload dist/*
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.pypi_token }}
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.pypi_token }}
17 changes: 16 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
rev: v4.3.0
hooks:
- id: check-yaml
- id: check-toml
- id: end-of-file-fixer
- id: trailing-whitespace

- repo: local
hooks:
Expand All @@ -12,3 +14,16 @@ repos:
entry: make lint
types: [python]
language: system
pass_filenames: false
- id: mypy
name: Mypy
entry: make mypy
types: [python]
language: system
pass_filenames: false

- repo: https://github.com/asottile/pyupgrade
rev: v2.38.2
hooks:
- id: pyupgrade
entry: pyupgrade --py37-plus
22 changes: 12 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
.DEFAULT_GOAL := all
isort = isort annotated_types tests
black = black annotated_types tests
paths = annotated_types tests

.PHONY: install
install:
pip install -r tests/requirements.txt
pip install -r tests/requirements-linting.txt
poetry install
pip install -r requirements/all.txt
pre-commit install

.PHONY: generate-dependencies
generate-dependencies:
pip-compile --resolver backtracking --output-file=requirements/linting.txt requirements/linting.in
pip-compile --resolver backtracking --output-file=requirements/testing.txt requirements/testing.in

.PHONY: format
format:
$(isort)
$(black)
isort $(paths)
black $(paths)

.PHONY: lint
lint:
flake8 --max-complexity 10 --max-line-length 120 --ignore E203,W503 annotated_types tests
$(isort) --check-only --df
$(black) --check
flake8 $(paths)
isort $(paths) --check-only --df
black $(paths) --check

.PHONY: test
test:
Expand Down
18 changes: 0 additions & 18 deletions poetry.lock

This file was deleted.

2 changes: 0 additions & 2 deletions poetry.toml

This file was deleted.

33 changes: 18 additions & 15 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
[tool.poetry]
[project]
name = "annotated-types"
# version is set from annotated-types/__init__.py::__version__
version = "0"
description = "Reusable constraint types to use with typing.Annotated"
authors = [
"Samuel Colvin <s@mulecolvin.com>",
"Adrian Garcia Badaracco <1755071+adriangb@users.noreply.github.com>",
"Zac Hatfield-Dodds <zac@zhd.dev>",
{name = "Samuel Colvin", email = "s@muelcolvin.com"},
{name = "Adrian Garcia Badaracco", email = "1755071+adriangb@users.noreply.github.com"},
{name = "Zac Hatfield-Dodds", email = "zac@zhd.dev"},
]
readme = "README.md"
repository = "https://github.com/annotated-types/annotated-types"
license = "MIT"
license = {file = "LICENSE"}
classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
Expand All @@ -25,28 +23,33 @@ classifiers = [
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Topic :: Software Development :: Libraries :: Python Modules",
"Typing :: Typed",
]

[tool.poetry.dependencies]
python = "^3.7.0"
typing-extensions = {version = "^4.0.0", python = "<3.9.0"}
requires-python = ">=3.7"
dependencies = ["typing-extensions>=4.0.0; python_version<'3.9'"]
dynamic = ["version"]

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.poetry-version-plugin]
source = "init"
[tool.hatch.version]
path = "annotated_types/__init__.py"

[tool.pytest.ini_options]
testpaths = "tests"
filterwarnings = "error"

[tool.flake8]
max_line_length = 120
max_complexity = 10
ignore = ["E203", "W503"]

[tool.coverage.run]
source = ["annotated_types"]
omit = ["annotated_types/_compat37.py", "annotated_types/_compat38.py"]
branch = true

[tool.coverage.report]
Expand Down
2 changes: 2 additions & 0 deletions requirements/all.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-r ./linting.txt
-r ./testing.txt
6 changes: 6 additions & 0 deletions requirements/linting.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
black
flake8
flake8-pyproject
isort[colors]
mypy
pre-commit
66 changes: 66 additions & 0 deletions requirements/linting.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#
# This file is autogenerated by pip-compile with python 3.10
# To update, run:
#
# pip-compile --output-file=requirements/linting.txt --resolver=backtracking requirements/linting.in
#
black==22.8.0
# via -r requirements/linting.in
cfgv==3.3.1
# via pre-commit
click==8.1.3
# via black
colorama==0.4.5
# via isort
distlib==0.3.6
# via virtualenv
filelock==3.8.0
# via virtualenv
flake8==5.0.4
# via
# -r requirements/linting.in
# flake8-pyproject
flake8-pyproject==1.1.0.post0
# via -r requirements/linting.in
identify==2.5.5
# via pre-commit
isort[colors]==5.10.1
# via -r requirements/linting.in
mccabe==0.7.0
# via flake8
mypy==0.971
# via -r requirements/linting.in
mypy-extensions==0.4.3
# via
# black
# mypy
nodeenv==1.7.0
# via pre-commit
pathspec==0.10.1
# via black
platformdirs==2.5.2
# via
# black
# virtualenv
pre-commit==2.20.0
# via -r requirements/linting.in
pycodestyle==2.9.1
# via flake8
pyflakes==2.5.0
# via flake8
pyyaml==6.0
# via pre-commit
toml==0.10.2
# via pre-commit
tomli==2.0.1
# via
# black
# flake8-pyproject
# mypy
typing-extensions==4.3.0
# via mypy
virtualenv==20.16.5
# via pre-commit

# The following packages are considered to be unsafe in a requirements file:
# setuptools
4 changes: 4 additions & 0 deletions requirements/testing.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
coverage
pytest
pytest-mock
pytest-sugar
35 changes: 35 additions & 0 deletions requirements/testing.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#
# This file is autogenerated by pip-compile with python 3.10
# To update, run:
#
# pip-compile --output-file=requirements/testing.txt --resolver=backtracking requirements/testing.in
#
attrs==22.1.0
# via pytest
coverage==6.4.4
# via -r requirements/testing.in
iniconfig==1.1.1
# via pytest
packaging==21.3
# via
# pytest
# pytest-sugar
pluggy==1.0.0
# via pytest
py==1.11.0
# via pytest
pyparsing==3.0.9
# via packaging
pytest==7.1.3
# via
# -r requirements/testing.in
# pytest-mock
# pytest-sugar
pytest-mock==3.8.2
# via -r requirements/testing.in
pytest-sugar==0.9.5
# via -r requirements/testing.in
termcolor==2.0.1
# via pytest-sugar
tomli==2.0.1
# via pytest
6 changes: 0 additions & 6 deletions tests/requirements-linting.txt

This file was deleted.

6 changes: 0 additions & 6 deletions tests/requirements.txt

This file was deleted.