Skip to content

Commit 0730b36

Browse files
committed
chore: extract glob for pyupgrade to separate script for cross-platform compatibility
'sh' in tox.ini does not work on Windows in PowerShell. Signed-off-by: Peter Schuster <p.schuster@pilz.de>
1 parent ec2f604 commit 0730b36

2 files changed

Lines changed: 19 additions & 4 deletions

File tree

tools/run_pyupgrade.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env python3
2+
3+
# This file is a cross platform wrapper for pyupgrade to pass a list of all files with relevant extension to pyupgrade.
4+
5+
import sys
6+
from pathlib import Path
7+
8+
from pyupgrade._main import main
9+
10+
files = sorted({
11+
str(p)
12+
for d in ['cyclonedx', 'typings', 'tests', 'tools', 'examples']
13+
for ext in ['*.py', '*.pyi']
14+
for p in Path(d).rglob(ext)
15+
})
16+
17+
sys.argv = [sys.argv[0], '--py39-plus', *sys.argv[1:], *files]
18+
main()

tox.ini

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,7 @@ commands =
5252
poetry run deptry -v .
5353

5454
[testenv:pyupgrade]
55-
allowlist_externals = poetry, sh
56-
commands = sh -c "\
57-
find cyclonedx typings tests tools examples -type f \( -name '*.py' -or -name '*.pyi' \) -print0 \
58-
| xargs -0 poetry run pyupgrade --py39-plus {posargs} "
55+
commands = poetry run python tools/run_pyupgrade.py {posargs}
5956

6057
[testenv:isort]
6158
commands = poetry run isort .

0 commit comments

Comments
 (0)