File tree Expand file tree Collapse file tree 5 files changed +23
-7
lines changed Expand file tree Collapse file tree 5 files changed +23
-7
lines changed Original file line number Diff line number Diff line change 1
1
repos :
2
2
- repo : https://github.com/asottile/reorder_python_imports
3
- rev : v1.9.0
3
+ rev : v3.0.1
4
4
hooks :
5
5
- id : reorder-python-imports
6
6
- repo : https://github.com/psf/black
7
- rev : 20.8b1
7
+ rev : 22.3.0
8
8
hooks :
9
9
- id : black
10
10
- repo : https://github.com/pre-commit/mirrors-prettier
11
- rev : v2.2 .1
11
+ rev : v2.6 .1
12
12
hooks :
13
13
- id : prettier
14
14
- repo : https://gitlab.com/pycqa/flake8
15
- rev : " 3.8.4 "
15
+ rev : " 3.9.2 "
16
16
hooks :
17
17
- id : flake8
18
18
- repo : https://github.com/pre-commit/pre-commit-hooks
19
- rev : v3.4 .0
19
+ rev : v4.1 .0
20
20
hooks :
21
21
- id : end-of-file-fixer
22
22
- id : check-case-conflict
23
23
- id : check-executables-have-shebangs
24
24
- id : requirements-txt-fixer
25
25
- repo : https://github.com/pre-commit/mirrors-pylint
26
- rev : v3.0.0a3
26
+ rev : v3.0.0a4
27
27
hooks :
28
28
- id : pylint
29
29
args : [--disable=all, --enable=unused-import]
Original file line number Diff line number Diff line change 45
45
from subprocess import list2cmdline as join # pylint: disable=ungrouped-imports
46
46
47
47
48
- STREAM_LIMIT = 2 ** 23 # 8MB instead of default 64kb, override it if you need
48
+ STREAM_LIMIT = 2 ** 23 # 8MB instead of default 64kb, override it if you need
49
49
50
50
51
51
async def _read_stream (stream : StreamReader , callback : Callable [..., Any ]) -> None :
Original file line number Diff line number Diff line change @@ -31,6 +31,11 @@ def test_get_version_python(py_package):
31
31
assert util .get_version () == "0.0.2a0"
32
32
33
33
34
+ def test_get_version_pyproject (py_package ):
35
+ os .unlink ("setup.py" )
36
+ assert util .get_version () == "0.0.1"
37
+
38
+
34
39
def test_get_version_multipython (py_multipackage ):
35
40
prev_dir = os .getcwd ()
36
41
for package in py_multipackage :
Original file line number Diff line number Diff line change @@ -85,6 +85,9 @@ def pyproject_template(sub_packages=[]):
85
85
[build-system]
86
86
requires = ["setuptools>=40.8.0", "wheel"]
87
87
build-backend = "setuptools.build_meta"
88
+
89
+ [project]
90
+ version = "0.0.1"
88
91
"""
89
92
if sub_packages :
90
93
res += f"""
Original file line number Diff line number Diff line change @@ -136,6 +136,14 @@ def get_version():
136
136
"""Get the current package version"""
137
137
if SETUP_PY .exists ():
138
138
return run ("python setup.py --version" ).split ("\n " )[- 1 ]
139
+ elif PYPROJECT .exists ():
140
+ text = PYPROJECT .read_text (encoding = "utf-8" )
141
+ data = toml .loads (text )
142
+ project = data .get ("project" , {})
143
+ version = project .get ("version" )
144
+ if not version : # pragma: no cover
145
+ raise ValueError ("No version identifier could be found!" )
146
+ return version
139
147
elif PACKAGE_JSON .exists ():
140
148
return json .loads (PACKAGE_JSON .read_text (encoding = "utf-8" )).get ("version" , "" )
141
149
else : # pragma: no cover
You can’t perform that action at this time.
0 commit comments