Skip to content

Commit

Permalink
Switch to pyproject.toml and deprecate the __version__ attr (#560)
Browse files Browse the repository at this point in the history
* Switch to pyproject.toml
* Improve the implementation and wording
* Add `build` package and update dependencies
* Deprecate the `__version__` attribute.

---------

Co-authored-by: Grey Li <withlihui@gmail.com>
  • Loading branch information
180909 and greyli committed Apr 21, 2024
1 parent c597b31 commit 3486313
Show file tree
Hide file tree
Showing 14 changed files with 167 additions and 176 deletions.
34 changes: 34 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[flake8]
# B = bugbear
# E = pycodestyle errors
# F = flake8 pyflakes
# W = pycodestyle warnings
# B9 = bugbear opinions
# ISC = implicit-str-concat
# Q0 = quotes
select = B, E, F, W, B9, ISC, Q0
# flake8-quotes
inline-quotes = single
multiline-quotes = double
docstring-quotes = double
avoid-escape = True

ignore =
# bin op line break, invalid
W503
# up to 88 allowed by bugbear B950
max-line-length = 100
per-file-ignores =
# modules export names
src/apiflask/__init__.py: F401
src/apiflask/fields.py: F401
src/apiflask/validators.py: F401
src/apiflask/views.py: F401
# HTML templates
src/apiflask/ui_templates.py: E501, B950
exclude =
# only used when running flake8 manually
.*
*.txt
*.md
__pycache__
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ repos:
- flake8-implicit-str-concat
- flake8-quotes
args:
- --config=./setup.cfg
- --config=.flake8
- repo: https://github.com/peterdemin/pip-compile-multi
rev: v2.4.5
hooks:
Expand Down
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

Released: --

- Deprecate the `__version__` attribute. Use feature detection or `importlib.metadata.version("apiflask")` instead.


## Version 2.1.1

Expand Down
77 changes: 77 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
[project]
name = "APIFlask"
description = "A lightweight web API framework based on Flask and marshmallow-code projects."
readme = "README.md"
license = { text = "MIT" }
authors = [{ name = "Grey Li", email = "withlihui@gmail.com" }]
version = "2.1.2-dev"
classifiers = [
"Development Status :: 3 - Alpha",
"Environment :: Web Environment",
"Framework :: Flask",
"Intended Audience :: Developers",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Topic :: Internet :: WWW/HTTP :: Dynamic Content",
"Topic :: Internet :: WWW/HTTP :: WSGI",
"Topic :: Internet :: WWW/HTTP :: WSGI :: Application",
"Topic :: Software Development :: Libraries :: Application Frameworks",
]
dependencies = [
"flask >= 2",
"flask-marshmallow >= 1.0.0",
"marshmallow >= 3.20",
"webargs >= 8.3",
"flask-httpauth >= 4",
"apispec >= 6",
]

[project.urls]
Documentation = "https://apiflask.com/docs"
Changes = "https://apiflask.com/changelog"
"Source Code" = "https://github.com/apiflask/apiflask"
"Issue Tracker" = "https://github.com/apiflask/apiflask/issues"
Donate = "https://opencollective.com/apiflask"

[project.optional-dependencies]
dotenv = ["python-dotenv"]
async = ["asgiref>=3.2"]
yaml = ["pyyaml"]

[project.scripts]
apiflask = "flask.cli:main"
spec = "apiflask.commands:spec_command"

[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[tool.mypy]
files = ["src/apiflask"]
allow_redefinition = true
warn_redundant_casts = true
warn_unused_configs = true
no_implicit_optional = true
local_partial_types = true
strict_equality = true
warn_return_any = true
warn_unreachable = true
disallow_untyped_calls = true

[[tool.mypy.overrides]]
module = ["flask_marshmallow.*", "apispec.*", "flask_httpauth.*"]
ignore_missing_imports = true

[tool.pytest.ini_options]
testpaths = ["tests", "examples"]
filterwarnings = ["ignore::UserWarning"]
addopts = ["--cov=apiflask", "--cov-branch", "--cov-report=term-missing"]

[tool.coverage.run]
omit = ["src/apiflask/_decorators.py", "src/apiflask/views.py"]
1 change: 1 addition & 0 deletions requirements/dev.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
pip-compile-multi
tox
pre-commit
build
14 changes: 8 additions & 6 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SHA1:81bbdb3ae0566a9508205bdcd58cf2330bc99c72
# SHA1:e65579d34c70903046b39ed1a1670b0bc06d7dcf
#
# This file is autogenerated by pip-compile-multi
# To update, run:
Expand All @@ -9,8 +9,10 @@
-r examples.txt
-r tests.txt
-r typing.txt
build==1.1.1
# via pip-tools
build==1.2.1
# via
# -r requirements/dev.in
# pip-tools
cachetools==5.3.3
# via tox
cfgv==3.4.0
Expand All @@ -19,11 +21,11 @@ chardet==5.2.0
# via tox
distlib==0.3.8
# via virtualenv
filelock==3.13.3
filelock==3.13.4
# via
# tox
# virtualenv
identify==2.5.35
identify==2.5.36
# via pre-commit
nodeenv==1.8.0
# via pre-commit
Expand All @@ -43,7 +45,7 @@ toposort==1.10
# via pip-compile-multi
tox==4.14.2
# via -r requirements/dev.in
virtualenv==20.25.1
virtualenv==20.25.3
# via
# pre-commit
# tox
Expand Down
17 changes: 8 additions & 9 deletions requirements/docs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,21 @@ colorama==0.4.6
# mkdocs-material
ghp-import==2.1.0
# via mkdocs
griffe==0.42.1
griffe==0.44.0
# via mkdocstrings-python
idna==3.6
idna==3.7
# via requests
jinja2==3.1.3
# via
# mkdocs
# mkdocs-material
# mkdocstrings
markdown==3.5.2
markdown==3.6
# via
# mkdocs
# mkdocs-autorefs
# mkdocs-material
# mkdocstrings
# mkdocstrings-python
# pymdown-extensions
markupsafe==2.1.5
# via
Expand All @@ -53,15 +52,15 @@ mkdocs==1.5.3
# mkdocstrings
mkdocs-autorefs==1.0.1
# via mkdocstrings
mkdocs-material==9.5.15
mkdocs-material==9.5.18
# via -r requirements/docs.in
mkdocs-material-extensions==1.3.1
# via mkdocs-material
mkdocstrings==0.24.1
mkdocstrings==0.24.3
# via
# -r requirements/docs.in
# mkdocstrings-python
mkdocstrings-python==1.9.0
mkdocstrings-python==1.10.0
# via -r requirements/docs.in
packaging==24.0
# via mkdocs
Expand All @@ -75,7 +74,7 @@ platformdirs==4.2.0
# mkdocstrings
pygments==2.17.2
# via mkdocs-material
pymdown-extensions==10.7.1
pymdown-extensions==10.8
# via
# mkdocs-material
# mkdocstrings
Expand All @@ -88,7 +87,7 @@ pyyaml==6.0.1
# pyyaml-env-tag
pyyaml-env-tag==0.1
# via mkdocs
regex==2023.12.25
regex==2024.4.16
# via mkdocs-material
requests==2.31.0
# via mkdocs-material
Expand Down
11 changes: 6 additions & 5 deletions requirements/examples.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ click==8.1.7
# via flask
cryptography==42.0.5
# via authlib
flask==3.0.2
flask==3.0.3
# via flask-sqlalchemy
flask-sqlalchemy==3.1.1
# via -r requirements/examples.in
greenlet==3.0.3
# via sqlalchemy
itsdangerous==2.1.2
itsdangerous==2.2.0
# via flask
jinja2==3.1.3
# via flask
Expand All @@ -37,15 +37,16 @@ mypy-extensions==1.0.0
# via typing-inspect
packaging==24.0
# via marshmallow
pycparser==2.21
pycparser==2.22
# via cffi
sqlalchemy==2.0.29
# via flask-sqlalchemy
typing-extensions==4.10.0
typing-extensions==4.11.0
# via
# marshmallow-dataclass
# sqlalchemy
# typing-inspect
typing-inspect==0.9.0
# via marshmallow-dataclass
werkzeug==3.0.1
werkzeug==3.0.2
# via flask
6 changes: 3 additions & 3 deletions requirements/min-versions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ flask-sqlalchemy==2.5.1
# via -r requirements/min-versions.in
greenlet==3.0.3
# via sqlalchemy
itsdangerous==2.1.2
itsdangerous==2.2.0
# via flask
jinja2==3.1.3
# via flask
Expand All @@ -50,13 +50,13 @@ packaging==24.0
# flask-marshmallow
# marshmallow
# webargs
pycparser==2.21
pycparser==2.22
# via cffi
sqlalchemy==1.4.49
# via
# -r requirements/min-versions.in
# flask-sqlalchemy
typing-extensions==4.10.0
typing-extensions==4.11.0
# via typing-inspect
typing-inspect==0.9.0
# via marshmallow-dataclass
Expand Down
8 changes: 6 additions & 2 deletions requirements/tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ charset-normalizer==3.3.2
# via requests
coverage[toml]==7.4.4
# via pytest-cov
idna==3.6
idna==3.7
# via requests
iniconfig==2.0.0
# via pytest
Expand All @@ -42,7 +42,7 @@ packaging==24.0
# via pytest
pathable==0.4.3
# via jsonschema-path
pluggy==1.4.0
pluggy==1.5.0
# via pytest
py==1.11.0
# via pytest
Expand Down Expand Up @@ -71,5 +71,9 @@ six==1.16.0
# via rfc3339-validator
toml==0.10.2
# via pytest
tomli==2.0.1
# via coverage
typing-extensions==4.11.0
# via asgiref
urllib3==2.2.1
# via requests
4 changes: 3 additions & 1 deletion requirements/typing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@ mypy==1.9.0
# via -r requirements/typing.in
mypy-extensions==1.0.0
# via mypy
typing-extensions==4.10.0
tomli==2.0.1
# via mypy
typing-extensions==4.11.0
# via mypy

0 comments on commit 3486313

Please sign in to comment.