Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jan 6, 2023
1 parent b00799f commit 3fb569a
Show file tree
Hide file tree
Showing 2 changed files with 120 additions and 123 deletions.
2 changes: 1 addition & 1 deletion setup_cfg_fmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def _tox_envlist(setup_cfg: str) -> Generator[str, None, None]:
TOX_ENV = re.compile(r'py3(\d+)')


def _python_requires(setup_cfg: str, *, min_py_version: tuple[int, int] | None) -> str :
def _python_requires(setup_cfg: str, *, min_py_version: tuple[int, int] | None) -> str:
cfg = NoTransformConfigParser()
cfg.read(setup_cfg)
current_value = cfg.get('options', 'python_requires', fallback='')
Expand Down
241 changes: 119 additions & 122 deletions tests/setup_cfg_fmt_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,17 +148,17 @@ def test_rewrite_requires(which, input_tpl, expected, tmpdir):
'name = pkg\n',
'[metadata]\n'
'name = pkg\n'
'version = 1.0\n'
'classifiers =\n'
' Programming Language :: Python :: 3\n'
' Programming Language :: Python :: 3 :: Only\n'
'\n'
'[options]\n'
'python_requires = >=3.7\n'
'\n'
'[bdist_wheel]\n'
'universal = true\n',
'name = pkg\n'
'version = 1.0\n'
'classifiers =\n'
' Programming Language :: Python :: 3\n'
' Programming Language :: Python :: 3 :: Only\n'
'\n'
'[options]\n'
'python_requires = >=3.7\n'
'\n'
'[bdist_wheel]\n'
'universal = true\n',
id='orders fields and sections',
),
Expand All @@ -174,20 +174,20 @@ def test_rewrite_requires(which, input_tpl, expected, tmpdir):
'where = src\n',
'[metadata]\n'
'name = pkg\n'
'version = 1.0\n'
'classifiers =\n'
' Programming Language :: Python :: 3\n'
' Programming Language :: Python :: 3 :: Only\n'
'\n'
'[options]\n'
'python_requires = >=3.7\n'
'\n'
'[options.packages.find]\n'
'where = src\n'
'\n'
'[bdist_wheel]\n'
'universal = true\n',
'name = pkg\n'
'version = 1.0\n'
'classifiers =\n'
' Programming Language :: Python :: 3\n'
' Programming Language :: Python :: 3 :: Only\n'
'\n'
'[options]\n'
'python_requires = >=3.7\n'
'\n'
'[options.packages.find]\n'
'where = src\n'
'\n'
'[bdist_wheel]\n'
'universal = true\n',
id='orders sections (options.packages.find)',
),
Expand Down Expand Up @@ -217,16 +217,16 @@ def test_rewrite_requires(which, input_tpl, expected, tmpdir):
' License :: OSI Approved :: MIT License\n'
' Programming Language :: Python :: 3 :: Only\n',
'[metadata]\n'
'name = pkg\n'
'version = 1.0\n'
'classifiers =\n'
' License :: OSI Approved :: MIT License\n'
' Programming Language :: Python :: 3\n'
' Programming Language :: Python :: 3 :: Only\n'
'\n'
'[options]\n'
'python_requires = >=3.7\n',
'[metadata]\n'
'name = pkg\n'
'version = 1.0\n'
'classifiers =\n'
' License :: OSI Approved :: MIT License\n'
' Programming Language :: Python :: 3\n'
' Programming Language :: Python :: 3 :: Only\n'
'\n'
'[options]\n'
'python_requires = >=3.7\n',
id='sorts classifiers',
),
Expand All @@ -240,18 +240,18 @@ def test_rewrite_requires(which, input_tpl, expected, tmpdir):
'author = john\n',
'[metadata]\n'
'name = pkg\n'
'author = john\n'
'author_email = [email protected]\n'
'maintainer = jane\n'
'maintainer_email = [email protected]\n'
'license = foo\n'
'classifiers =\n'
' Programming Language :: Python :: 3\n'
' Programming Language :: Python :: 3 :: Only\n'
'\n'
'[options]\n'
'python_requires = >=3.7\n',
'name = pkg\n'
'author = john\n'
'author_email = [email protected]\n'
'maintainer = jane\n'
'maintainer_email = [email protected]\n'
'license = foo\n'
'classifiers =\n'
' Programming Language :: Python :: 3\n'
' Programming Language :: Python :: 3 :: Only\n'
'\n'
'[options]\n'
'python_requires = >=3.7\n',
id='orders authors and maintainers',
),
Expand All @@ -262,15 +262,15 @@ def test_rewrite_requires(which, input_tpl, expected, tmpdir):
'maintainer-email = [email protected]\n',
'[metadata]\n'
'name = pkg\n'
'author_email = [email protected]\n'
'maintainer_email = [email protected]\n'
'classifiers =\n'
' Programming Language :: Python :: 3\n'
' Programming Language :: Python :: 3 :: Only\n'
'\n'
'[options]\n'
'python_requires = >=3.7\n',
'name = pkg\n'
'author_email = [email protected]\n'
'maintainer_email = [email protected]\n'
'classifiers =\n'
' Programming Language :: Python :: 3\n'
' Programming Language :: Python :: 3 :: Only\n'
'\n'
'[options]\n'
'python_requires = >=3.7\n',
id='normalize dashes to underscores in keys',
),
Expand Down Expand Up @@ -492,16 +492,13 @@ def test_license_does_not_set_when_licenses_matches(tmpdir):
'\n' \
'[options]\n' \
'python_requires = >=3.7\n'

tmpdir.join('LICENSE').write('COPYRIGHT (C) 2019 ME')
setup_cfg = tmpdir.join('setup.cfg')
setup_cfg.write(s)

assert not main((str(setup_cfg),))





def test_license_does_set_when_licenses_mismatches(tmpdir):
tmpdir.join('LICENSE').write('COPYRIGHT (C) 2019 ME')
Expand All @@ -521,11 +518,11 @@ def test_license_does_set_when_licenses_mismatches(tmpdir):
'version = 1.0\n'
'license_file = LICENSE\n'
'license_files = LICENSES\n'
'classifiers =\n'
' Programming Language :: Python :: 3\n'
' Programming Language :: Python :: 3 :: Only\n'
'\n'
'[options]\n'
'classifiers =\n'
' Programming Language :: Python :: 3\n'
' Programming Language :: Python :: 3 :: Only\n'
'\n'
'[options]\n'
'python_requires = >=3.7\n'
)

Expand All @@ -546,17 +543,17 @@ def test_rewrite_sets_license_type_and_classifier(tmpdir):

assert setup_cfg.read() == (
'[metadata]\n'
'name = pkg\n'
'version = 1.0\n'
'license = MIT\n'
'license_file = LICENSE\n'
'classifiers =\n'
' License :: OSI Approved :: MIT License\n'
' Programming Language :: Python :: 3\n'
' Programming Language :: Python :: 3 :: Only\n'
'\n'
'[options]\n'
'python_requires = >=3.7\n'
'name = pkg\n'
'version = 1.0\n'
'license = MIT\n'
'license_file = LICENSE\n'
'classifiers =\n'
' License :: OSI Approved :: MIT License\n'
' Programming Language :: Python :: 3\n'
' Programming Language :: Python :: 3 :: Only\n'
'\n'
'[options]\n'
'python_requires = >=3.7\n'
)


Expand Down Expand Up @@ -599,12 +596,12 @@ def test_rewrite_identifies_license(tmpdir):
'license = Zlib\n'
'license_file = LICENSE\n'
'classifiers =\n'
' License :: OSI Approved :: zlib/libpng License\n'
' Programming Language :: Python :: 3\n'
' Programming Language :: Python :: 3 :: Only\n'
'\n'
'[options]\n'
'python_requires = >=3.7\n'
' License :: OSI Approved :: zlib/libpng License\n'
' Programming Language :: Python :: 3\n'
' Programming Language :: Python :: 3 :: Only\n'
'\n'
'[options]\n'
'python_requires = >=3.7\n'
)


Expand Down Expand Up @@ -676,9 +673,9 @@ def test_strips_empty_options_and_sections(tmpdir, section, expected):
'[metadata]\n'
'name = pkg\n'
'version = 1.0\n'
'classifiers =\n'
' Programming Language :: Python :: 3\n'
' Programming Language :: Python :: 3 :: Only\n'
'classifiers =\n'
' Programming Language :: Python :: 3\n'
' Programming Language :: Python :: 3 :: Only\n'
f'{section}',
)

Expand All @@ -687,9 +684,9 @@ def test_strips_empty_options_and_sections(tmpdir, section, expected):
'[metadata]\n'
'name = pkg\n'
'version = 1.0\n'
'classifiers =\n'
' Programming Language :: Python :: 3\n'
' Programming Language :: Python :: 3 :: Only\n'
'classifiers =\n'
' Programming Language :: Python :: 3\n'
' Programming Language :: Python :: 3 :: Only\n'
f'{expected}'
)

Expand Down Expand Up @@ -772,20 +769,20 @@ def test_guess_python_requires_tox_ini_py310(tmpdir):

assert setup_cfg.read() == (
'[metadata]\n'
'name = pkg\n'
'version = 1.0\n'
'classifiers =\n'
' Programming Language :: Python :: 3\n'
' Programming Language :: Python :: 3 :: Only\n'
' Programming Language :: Python :: 3.7\n'
' Programming Language :: Python :: 3.8\n'
' Programming Language :: Python :: 3.9\n'
' Programming Language :: Python :: 3.10\n'
' Programming Language :: Python :: 3.11\n'
' Programming Language :: Python :: Implementation :: CPython\n'
'\n'
'[options]\n'
'python_requires = >=3.7\n'
'name = pkg\n'
'version = 1.0\n'
'classifiers =\n'
' Programming Language :: Python :: 3\n'
' Programming Language :: Python :: 3 :: Only\n'
' Programming Language :: Python :: 3.7\n'
' Programming Language :: Python :: 3.8\n'
' Programming Language :: Python :: 3.9\n'
' Programming Language :: Python :: 3.10\n'
' Programming Language :: Python :: 3.11\n'
' Programming Language :: Python :: Implementation :: CPython\n'
'\n'
'[options]\n'
'python_requires = >=3.7\n'
)


Expand All @@ -800,19 +797,19 @@ def test_guess_python_requires_ignores_insufficient_version_envs(tmpdir):
' Programming Language :: Python :: Implementation :: CPython\n',
)

assert main((str(setup_cfg), '--max-py-version=3.7',))
assert main((str(setup_cfg), '--max-py-version=3.7'))

assert setup_cfg.read() == (
'[metadata]\n'
'name = pkg\n'
'version = 1.0\n'
'classifiers =\n'
' Programming Language :: Python :: 3\n'
' Programming Language :: Python :: 3 :: Only\n'
' Programming Language :: Python :: Implementation :: CPython\n'
'\n'
'[options]\n'
'python_requires = >=3.7\n'
' Programming Language :: Python :: 3 :: Only\n'
' Programming Language :: Python :: Implementation :: CPython\n'
'\n'
'[options]\n'
'python_requires = >=3.7\n'
)


Expand Down Expand Up @@ -1049,12 +1046,12 @@ def test_rewrite_extras(tmpdir):
setup_cfg_content = (
'[metadata]\n'
'name = test\n'
'classifiers =\n'
' Programming Language :: Python :: 3\n'
' Programming Language :: Python :: 3 :: Only\n'
'\n'
'[options]\n'
'python_requires = >=3.7\n'
'classifiers =\n'
' Programming Language :: Python :: 3\n'
' Programming Language :: Python :: 3 :: Only\n'
'\n'
'[options]\n'
'python_requires = >=3.7\n'
'[options.extras_require]\n'
'dev =\n'
' pytest\n'
Expand All @@ -1072,12 +1069,12 @@ def test_rewrite_extras(tmpdir):
assert setup_cfg.read() == (
'[metadata]\n'
'name = test\n'
'classifiers =\n'
' Programming Language :: Python :: 3\n'
' Programming Language :: Python :: 3 :: Only\n'
'\n'
'[options]\n'
'python_requires = >=3.7\n'
'classifiers =\n'
' Programming Language :: Python :: 3\n'
' Programming Language :: Python :: 3 :: Only\n'
'\n'
'[options]\n'
'python_requires = >=3.7\n'
'\n'
'[options.extras_require]\n'
'ci =\n'
Expand Down Expand Up @@ -1281,10 +1278,10 @@ def test_leaves_casing_of_unrelated_settings(tmpdir):
'python_requires = >=3.7\n'
'\n'
'[tool:pytest]\n'
'DJANGO_SETTINGS_MODULE = test.test\n'
'DJANGO_SETTINGS_MODULE = test.test\n',
)

assert not main((str(setup_cfg),))
assert not main((str(setup_cfg),))


def test_natural_sort():
Expand Down

0 comments on commit 3fb569a

Please sign in to comment.