Skip to content

Commit 94a1b85

Browse files
authored
Add --py37-plus option (#157)
1 parent 4bf8982 commit 94a1b85

3 files changed

Lines changed: 30 additions & 1 deletion

File tree

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ Check `git diff` before committing!
107107

108108
### Python version options
109109

110+
**`--py37-plus`**
111+
Set the minimum Python syntax version to **3.7**. (Default: **3.8**)
112+
110113
**`--py38-plus`**
111114
Set the minimum Python syntax version to **3.8**. This is the default.
112115

python_typing_update/__main__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,13 @@ async def async_main(argv: list[str] | None = None) -> int:
8888
)
8989

9090
group_py_version = py_version_options.add_mutually_exclusive_group()
91+
group_py_version.add_argument(
92+
'--py37-plus',
93+
action='store_const', dest='min_version', const=(3, 7), default=(3, 8),
94+
)
9195
group_py_version.add_argument(
9296
'--py38-plus',
93-
action='store_const', dest='min_version', default=(3, 8), const=(3, 8),
97+
action='store_const', dest='min_version', const=(3, 8),
9498
help="Default"
9599
)
96100
group_py_version.add_argument(

tests/test_main.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,28 @@ async def test_main(
108108
await async_test_main(filename, control, argv, returncode, capsys)
109109

110110

111+
@pytest.mark.parametrize(
112+
('argv',),
113+
(
114+
pytest.param(['--py37-plus']),
115+
pytest.param(['--py38-plus']),
116+
pytest.param(['--py39-plus']),
117+
pytest.param(['--py310-plus']),
118+
),
119+
)
120+
async def test_py_version(
121+
argv: list[str] | None,
122+
capsys: CaptureFixture,
123+
) -> None:
124+
await async_test_main(
125+
filename='no_changes.py',
126+
control='no_changes_no_change.py',
127+
argv=argv,
128+
returncode=0,
129+
capsys=capsys,
130+
)
131+
132+
111133
@pytest.mark.parametrize(
112134
('filename', 'control', 'argv', 'returncode'),
113135
(

0 commit comments

Comments
 (0)