Skip to content

Commit ac320ca

Browse files
committed
Add glue pyproject updates to cookiecutter
1 parent b31ea2e commit ac320ca

File tree

17 files changed

+84
-27
lines changed

17 files changed

+84
-27
lines changed

cookiecutter/bootstrap/{{ cookiecutter.__project_name }}/pulp-glue{{ cookiecutter.__app_label_suffix }}/pyproject.toml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,6 @@ namespaces = true
3838
[tool.setuptools.package-data]
3939
"*" = ["py.typed", "locale/*/LC_MESSAGES/*.mo"]
4040

41-
[tool.black]
42-
line-length = 100
43-
44-
[tool.isort]
45-
profile = "black"
46-
line_length = 100
47-
4841
[tool.mypy]
4942
strict = true
5043
show_error_codes = true

cookiecutter/ci/hooks/post_gen_project.py

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,27 @@
44

55
import tomlkit
66

7-
# Merge pyproject.toml.update into pyproject.toml
8-
with open("pyproject.toml", "r") as fp:
9-
pyproject_toml = tomlkit.load(fp)
7+
for base_path in [
8+
".",
9+
"pulp-glue{{ cookiecutter.__app_label_suffix }}",
10+
]:
11+
# Merge pyproject.toml.update into pyproject.toml
12+
with open(os.path.join(base_path, "pyproject.toml"), "r") as fp:
13+
pyproject_toml = tomlkit.load(fp)
1014

11-
with open("pyproject.toml.update", "r") as fp:
12-
pyproject_toml_update = tomlkit.load(fp)
15+
with open(os.path.join(base_path, "pyproject.toml.update"), "r") as fp:
16+
pyproject_toml_update = tomlkit.load(fp)
1317

14-
# TODO How deep is your merge?
15-
# Is merging on the tool level appropriate?
16-
pyproject_toml["tool"].update(pyproject_toml_update["tool"])
18+
# TODO How deep is your merge?
19+
# Is merging on the tool level appropriate?
20+
pyproject_toml["tool"].update(pyproject_toml_update["tool"])
1721

18-
# Remove legacy tools.
19-
for tool in ["flake8", "black", "isort"]:
20-
pyproject_toml["tool"].pop(tool, None)
22+
# Remove legacy tools.
23+
for tool in ["flake8", "black", "isort"]:
24+
pyproject_toml["tool"].pop(tool, None)
2125

22-
with open("pyproject.toml", "w") as fp:
23-
tomlkit.dump(pyproject_toml, fp)
26+
with open(os.path.join(base_path, "pyproject.toml"), "w") as fp:
27+
tomlkit.dump(pyproject_toml, fp)
2428

2529
# Remove unwanted files
2630

@@ -31,6 +35,8 @@
3135
{%- if not cookiecutter.glue %}
3236
"pulp-glue{{ cookiecutter.__app_label_suffix }}",
3337
"CHANGES/pulp-glue{{ cookiecutter.__app_label_suffix }}",
38+
{%- else %}
39+
"pulp-glue{{ cookiecutter.__app_label_suffix }}/pyproject.toml.update",
3440
{%- endif %}
3541
{%- if not cookiecutter.app_label or not cookiecutter.glue %}
3642
".ci/scripts/check_cli_dependencies.py",
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{#
2+
This file is not templated for itself, but it is used to update sections in pyproject.toml.
3+
#}
4+
5+
[tool.setuptools.packages.find]
6+
# This section is managed by the cookiecutter templates.
7+
where = ["."]
8+
include = ["pulp_glue.*"]
9+
namespaces = true
10+
11+
[tool.setuptools.package-data]
12+
# This section is managed by the cookiecutter templates.
13+
"*" = ["py.typed"{% if cookiecutter.translations %}, "locale/*/LC_MESSAGES/*.mo"{% endif %}]
14+
15+
[tool.ruff]
16+
# This section is managed by the cookiecutter templates.
17+
line-length = 100
18+
19+
[tool.ruff.lint]
20+
# This section is managed by the cookiecutter templates.
21+
extend-select = ["I"]
22+
23+
[tool.mypy]
24+
# This section is managed by the cookiecutter templates.
25+
strict = true
26+
warn_unused_ignores = false
27+
show_error_codes = true
28+
files = "pulp_glue/**/*.py, tests/**/*.py"
29+
namespace_packages = true
30+
explicit_package_bases = true
31+
32+
[[tool.mypy.overrides]]
33+
# This section is managed by the cookiecutter templates.
34+
module = [
35+
"schema.*",
36+
]
37+
ignore_missing_imports = true

pulp-glue/pulp_glue/common/context.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from contextlib import ExitStack
99

1010
from packaging.specifiers import SpecifierSet
11+
1112
from pulp_glue.common.exceptions import (
1213
NotImplementedFake,
1314
OpenAPIError,

pulp-glue/pulp_glue/common/openapi.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import requests
1515
import urllib3
1616
from multidict import CIMultiDict, MutableMultiMapping
17+
1718
from pulp_glue.common import __version__
1819
from pulp_glue.common.exceptions import (
1920
OpenAPIError,

pulp-glue/pyproject.toml

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,29 +35,37 @@ repository = "https://github.com/pulp/pulp-cli"
3535
changelog = "https://pulpproject.org/pulp-cli/changes/"
3636

3737
[tool.setuptools.packages.find]
38+
# This section is managed by the cookiecutter templates.
3839
where = ["."]
3940
include = ["pulp_glue.*"]
4041
namespaces = true
4142

4243
[tool.setuptools.package-data]
44+
# This section is managed by the cookiecutter templates.
4345
"*" = ["py.typed", "locale/*/LC_MESSAGES/*.mo"]
4446

45-
[tool.black]
46-
line-length = 100
47-
48-
[tool.isort]
49-
profile = "black"
50-
line_length = 100
5147

5248
[tool.mypy]
49+
# This section is managed by the cookiecutter templates.
5350
strict = true
51+
warn_unused_ignores = false
5452
show_error_codes = true
5553
files = "pulp_glue/**/*.py, tests/**/*.py"
5654
namespace_packages = true
5755
explicit_package_bases = true
5856

5957
[[tool.mypy.overrides]]
58+
# This section is managed by the cookiecutter templates.
6059
module = [
6160
"schema.*",
6261
]
6362
ignore_missing_imports = true
63+
64+
[tool.ruff]
65+
# This section is managed by the cookiecutter templates.
66+
line-length = 100
67+
68+
[tool.ruff.lint]
69+
# This section is managed by the cookiecutter templates.
70+
extend-select = ["I"]
71+

pulp-glue/tests/conftest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import typing as t
44

55
import pytest
6+
67
from pulp_glue.common.context import PulpContext
78
from pulp_glue.common.openapi import BasicAuthProvider, OpenAPI
89

pulp-glue/tests/test_api_quirks.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from copy import deepcopy
22

33
import pytest
4+
45
from pulp_glue.common.context import _REGISTERED_API_QUIRKS, PulpContext
56

67
pytestmark = pytest.mark.glue

pulp-glue/tests/test_auth_provider.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import typing as t
22

33
import pytest
4+
from requests.auth import AuthBase
5+
46
from pulp_glue.common.exceptions import OpenAPIError
57
from pulp_glue.common.openapi import AuthProviderBase
6-
from requests.auth import AuthBase
78

89
pytestmark = pytest.mark.glue
910

pulp-glue/tests/test_authentication.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import typing as t
22

33
import pytest
4+
45
from pulp_glue.common.authentication import OAuth2ClientCredentialsAuth
56

67
pytestmark = pytest.mark.glue

0 commit comments

Comments
 (0)