Skip to content

Commit 58afa1a

Browse files
Migrate project to pyproject.toml and use VCS based automatic versioning
1 parent 23dfc21 commit 58afa1a

File tree

5 files changed

+220
-43
lines changed

5 files changed

+220
-43
lines changed

.gitignore

+5-1
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,8 @@ docs/_build/
6161
.DS_Store
6262

6363
# pyenv virtualenv
64-
.python-version
64+
.python-version
65+
66+
# Generated files
67+
_version.py
68+
_version.pyi

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ matrix:
88
- python: '3.8'
99
env: TOXENV=py37
1010
install:
11-
- python setup.py -q install
11+
- python -m pip install --upgrade --editable=./
1212
script:
1313
- nosetests test $EXTRA_ARGS
1414
- if [ "$TOXENV" = "py37" ]; then nosetests test37; fi

makefile

+26-2
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,42 @@
1-
.PHONY: dist test test37
1+
SHELL := bash
2+
.DELETE_ON_ERROR:
3+
.SHELLFLAGS := -ceu
4+
MAKEFLAGS += --no-builtin-rules \
5+
--warn-undefined-variables
6+
7+
.PHONY: dist pytest test test37 typeshed
28

39
dist:
4-
python3 setup.py sdist
10+
if ! python3 -m pip freeze | grep -q build; then python3 -m pip install --upgrade build; fi
11+
python3 -m build --outdir=dist --sdist --wheel ./
12+
13+
install_dev:
14+
python3 -m pip install --upgrade pip
15+
python3 -m pip install --upgrade --editable=./
16+
17+
typeshed:
18+
if ! command -v stubgen &>/dev/null; then python3 -m pip install --upgrade mypy; fi
19+
stubgen --output=typeshed/pyi --search-path=src src/inject
520

621
upload:
22+
if ! python3 -m pip freeze | grep -q twine; then python3 -m pip install --upgrade twine; fi
723
python3 -m twine upload dist/*
824

925
clean:
1026
rm -rf ./build/*
1127
rm -rf ./dist/*
28+
rm -rf ./.mypy_cache
29+
rm -rf ./.pytest_cache
30+
31+
pytest:
32+
if ! command -v pytest &>/dev/null; then python3 -m pip install --upgrade pytest; fi
33+
pytest test
1234

1335
test:
36+
if ! command -v nosetests &>/dev/null; then python3 -m pip install --upgrade nose; fi
1437
nosetests test
1538

1639
test37:
40+
if ! command -v nosetests &>/dev/null; then python3 -m pip install --upgrade nose; fi
1741
nosetests test
1842
nosetests test37

pyproject.toml

+188
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
[build-system]
2+
requires = ['hatchling', 'hatch-vcs']
3+
build-backend = 'hatchling.build'
4+
5+
[project]
6+
name = 'inject'
7+
dynamic = ['version']
8+
description = 'Python dependency injection framework.'
9+
license='Apache-2.0'
10+
readme = 'README.md'
11+
authors = [
12+
{ name = 'Ivan Korobkov', email = '[email protected]' },
13+
]
14+
maintainers = [
15+
{ name = 'Ivan Korobkov', email = '[email protected]' },
16+
]
17+
classifiers = [
18+
'Development Status :: 5 - Production/Stable',
19+
'Intended Audience :: Developers',
20+
'License :: OSI Approved :: Apache Software License',
21+
'Operating System :: OS Independent',
22+
'Programming Language :: Python',
23+
'Programming Language :: Python :: 3.6',
24+
'Programming Language :: Python :: 3.7',
25+
'Programming Language :: Python :: 3.8',
26+
'Programming Language :: Python :: 3.9',
27+
'Programming Language :: Python :: 3.10',
28+
'Programming Language :: Python :: 3.11',
29+
'Topic :: Software Development :: Libraries :: Python Modules',
30+
]
31+
dependencies = [
32+
]
33+
34+
[project.scripts]
35+
36+
[project.urls]
37+
Homepage = 'https://github.com/ivankorobkov/python-inject'
38+
39+
[tool.black]
40+
line-length = 120
41+
skip-string-normalization = true
42+
target_version = ['py39', 'py310', 'py311']
43+
include = '\.pyi?$'
44+
exclude = '''
45+
/(
46+
\.eggs
47+
| \.git
48+
| \.github
49+
| \.hg
50+
| \.idea
51+
| \.mypy_cache
52+
| \.tox
53+
| \.pyre_configuration
54+
| \.venv
55+
| _build
56+
| build
57+
| dist
58+
| var
59+
)
60+
'''
61+
62+
[tool.hatch.build.hooks.vcs]
63+
version-file = 'src/inject/_version.py'
64+
65+
[tool.hatch.build.targets.wheel]
66+
packages = [
67+
'src/inject',
68+
]
69+
70+
[tool.hatch.build.targets.wheel.force-include]
71+
'typeshed/pyi/inject' = 'typeshed/pyi/inject'
72+
73+
[tool.hatch.build.targets.wheel.shared-data]
74+
75+
[tool.hatch.version]
76+
source = 'vcs'
77+
78+
[tool.isort]
79+
case_sensitive = true
80+
include_trailing_comma = true
81+
line_length = 120
82+
multi_line_output = 3
83+
profile = 'black'
84+
85+
[tool.mypy]
86+
check_untyped_defs = true
87+
disallow_any_generics = true
88+
disallow_incomplete_defs = true
89+
disallow_subclassing_any = true
90+
disallow_untyped_calls = true
91+
disallow_untyped_decorators = true
92+
disallow_untyped_defs = true
93+
ignore_missing_imports = true
94+
mypy_path = ['typeshed/pyi']
95+
no_implicit_optional = true
96+
python_version = '3.11'
97+
warn_redundant_casts = true
98+
warn_return_any = true
99+
warn_unused_configs = true
100+
warn_unused_ignores = true
101+
102+
[tool.pyright]
103+
defineConstant = { DEBUG = true }
104+
exclude = []
105+
executionEnvironments = []
106+
ignore = []
107+
include = [
108+
'src/inject',
109+
'test',
110+
]
111+
pythonPlatform = 'Linux'
112+
pythonVersion = '3.11'
113+
reportMissingImports = true
114+
reportMissingTypeStubs = false
115+
stubPath = 'typeshed/import'
116+
117+
[tool.pytest.ini_options]
118+
addopts = '-rfEX --strict-markers --tb=long'
119+
minversion = '7.2'
120+
python_files = [
121+
'test_*.py',
122+
]
123+
testpaths = [
124+
'./test',
125+
]
126+
127+
[tool.ruff]
128+
ignore = [
129+
# Allow non-abstract empty methods in abstract base classes
130+
'B027',
131+
# Allow boolean positional values in function calls, like `dict.get(... True)`
132+
'FBT003',
133+
# Ignore checks for possible passwords
134+
'S105', 'S106', 'S107',
135+
# Ignore complexity
136+
'C901', 'PLR0911', 'PLR0912', 'PLR0913', 'PLR0915',
137+
'PLC1901', # empty string comparisons
138+
'PLW2901', # `for` loop variable overwritten
139+
'SIM114', # Combine `if` branches using logical `or` operator
140+
]
141+
line-length = 120
142+
select = [
143+
'A',
144+
'B',
145+
'C',
146+
'DTZ',
147+
'E',
148+
'EM',
149+
'F',
150+
'FBT',
151+
'I',
152+
'ICN',
153+
'ISC',
154+
'N',
155+
'PLC',
156+
'PLE',
157+
'PLR',
158+
'PLW',
159+
'Q',
160+
'RUF',
161+
'S',
162+
'SIM',
163+
'T',
164+
'TID',
165+
'UP',
166+
'W',
167+
'YTT',
168+
]
169+
target-version = ['py39', 'py310', 'py311']
170+
unfixable = [
171+
# Don't touch unused imports
172+
'F401',
173+
]
174+
175+
[tool.ruff.flake8-quotes]
176+
inline-quotes = 'single'
177+
178+
[tool.ruff.flake8-tidy-imports]
179+
ban-relative-imports = 'all'
180+
181+
[tool.ruff.isort]
182+
known-first-party = [
183+
'inject',
184+
]
185+
186+
[tool.ruff.per-file-ignores]
187+
# Tests can use magic values, assertions, and relative imports
188+
'/**/test_*.py' = ['PLR2004', 'S101', 'TID252']

setup.py

-39
This file was deleted.

0 commit comments

Comments
 (0)