File tree Expand file tree Collapse file tree 4 files changed +16
-10
lines changed
project-template/{{cookiecutter.repo_name}} Expand file tree Collapse file tree 4 files changed +16
-10
lines changed Original file line number Diff line number Diff line change @@ -61,3 +61,16 @@ def minimum_python_version(self) -> str:
6161 costly to run the tests for all `python_versions` or we need a single metric.
6262 """
6363 return str (min ([Version .from_string (v ) for v in self .python_versions ]))
64+
65+ @computed_field # type: ignore[misc]
66+ @property
67+ def pyupgrade_argument (self ) -> tuple [str , ...]:
68+ """
69+ Minimum Python version declared from the `python_versions` list
70+
71+ This is used in specific testing scenarios where it would be either
72+ costly to run the tests for all `python_versions` or we need a single metric.
73+ """
74+ version_parts = self .minimum_python_version .split ("." )[:2 ]
75+ version_number = "" .join (version_parts )
76+ return (f"--py{ version_number } -plus" ,)
Original file line number Diff line number Diff line change 88from exasol .toolbox .nox ._shared import (
99 Mode ,
1010 _version ,
11+ check_for_config_attribute ,
1112 python_files ,
1213)
1314from noxconfig import (
1415 PROJECT_CONFIG ,
1516 Config ,
1617)
1718
18- _PYUPGRADE_ARGS = ("--py39-plus" ,)
19-
2019
2120def _code_format (session : Session , mode : Mode , files : Iterable [str ]) -> None :
2221 def command (* args : str ) -> Iterable [str ]:
@@ -27,10 +26,10 @@ def command(*args: str) -> Iterable[str]:
2726
2827
2928def _pyupgrade (session : Session , config : Config , files : Iterable [str ]) -> None :
30- pyupgrade_args = getattr (config , "pyupgrade_args" , _PYUPGRADE_ARGS )
29+ check_for_config_attribute (config , "pyupgrade_argument" )
3130 session .run (
3231 "pyupgrade" ,
33- * pyupgrade_args ,
32+ * config . pyupgrade_argument ,
3433 "--exit-zero-even-if-changed" ,
3534 * files ,
3635 )
Original file line number Diff line number Diff line change @@ -63,10 +63,6 @@ class Config(BaseConfig):
6363 ".github" ,
6464 )
6565 plugins : Iterable [object ] = (UpdateTemplates ,)
66- # need --keep-runtime-typing, as pydantic with python3.9 does not accept str | None
67- # format, and it is not resolved with from __future__ import annotations. pyupgrade
68- # will keep switching Optional[str] to str | None leading to issues.
69- pyupgrade_args : Iterable [str ] = ("--py39-plus" , "--keep-runtime-typing" )
7066
7167
7268PROJECT_CONFIG = Config (
Original file line number Diff line number Diff line change @@ -17,8 +17,6 @@ class Config(BaseConfig):
1717 / "version.py"
1818 )
1919 path_filters : Iterable [str ] = ()
20- pyupgrade_args : Iterable [str ] = (
21- "--py{{cookiecutter.python_version_min | replace('.', '')}}-plus" ,)
2220 plugins : Iterable [object ] = ()
2321
2422PROJECT_CONFIG = Config ()
You can’t perform that action at this time.
0 commit comments