Skip to content

Commit 6a88f7d

Browse files
author
Michael Johansen
committed
Update _get_application_import_names to have fall-backs
Signed-off-by: Michael Johansen <[email protected]>
1 parent 3d83096 commit 6a88f7d

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

ni_python_styleguide/_cli.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,22 @@ def _read_pyproject_toml(ctx, param, value):
3939

4040
def _get_application_import_names(pyproject):
4141
"""Returns the application package name the config."""
42-
# Otherwise override with what was specified
42+
# Use the tool-specific import names if specified
4343
app_name = (
4444
pyproject.get("tool", {})
4545
.get("ni-python-styleguide", {})
4646
.get("application-import-names", "")
4747
)
4848

49-
# Allow the poetry name as a fallback
49+
# Next fall back to project.import-names
50+
if not app_name:
51+
app_name = pyproject.get("project", {}).get("import-names", "")
52+
53+
# Next fall back to project.name (replace hyphens)
54+
if not app_name:
55+
app_name = pyproject.get("project", {}).get("name", "").replace("-", "_")
56+
57+
# Next fall back to tool.poetry.name (replace hyphens)
5058
if not app_name:
5159
app_name = pyproject.get("tool", {}).get("poetry", {}).get("name", "").replace("-", "_")
5260

0 commit comments

Comments
 (0)