Skip to content

Commit 4aa753f

Browse files
committed
fix: .git/.gitignore/Makefile as project root
1 parent 5ae18c0 commit 4aa753f

3 files changed

Lines changed: 26 additions & 14 deletions

File tree

src/nitpick/constants.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
JAVASCRIPT_PACKAGE_JSON = "package.json"
3838
JMEX_NITPICK_MINIMUM_VERSION = jmespath.compile("nitpick.minimum_version")
3939
JMEX_NITPICK_STYLES_INCLUDE = jmespath.compile("nitpick.styles.include")
40+
MAKEFILE = "Makefile"
4041
MERGED_STYLE_TOML = "merged-style.toml"
4142
NITPICK_STYLE_TOML = "nitpick-style.toml"
4243
PRE_COMMIT_CONFIG_YAML = ".pre-commit-config.yaml"
@@ -60,13 +61,16 @@
6061

6162
# These depend on some constants above, so they can't be sorted automatically
6263
ROOT_PYTHON_FILES = ("app.py", "wsgi.py", "autoapp.py", PYTHON_MANAGE_PY)
63-
ROOT_FILES = (
64+
ROOT_FILES_DIRS = (
6465
# keep-sorted start
6566
*ROOT_PYTHON_FILES,
6667
DOT_NITPICK_TOML,
68+
GIT_DIR,
69+
GIT_IGNORE,
6770
GOLANG_MOD,
6871
GOLANG_SUM,
6972
JAVASCRIPT_PACKAGE_JSON,
73+
MAKEFILE,
7074
NITPICK_STYLE_TOML,
7175
PRE_COMMIT_CONFIG_YAML,
7276
PYTHON_PIPFILE_STAR,

src/nitpick/core.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
PROJECT_NAME,
3636
PYTHON_MANAGE_PY,
3737
PYTHON_PYPROJECT_TOML,
38-
ROOT_FILES,
38+
ROOT_FILES_DIRS,
3939
ROOT_PYTHON_FILES,
4040
)
4141
from nitpick.exceptions import QuitComplainingError
@@ -173,7 +173,7 @@ def echo(self, message: str):
173173
def confirm_project_root(dir_: PathOrStr | None = None) -> Path:
174174
"""Confirm this is the root dir of the project (the one that has one of the ``ROOT_FILES``)."""
175175
possible_root_dir = Path(dir_ or Path.cwd()).resolve()
176-
root_files = glob_files(possible_root_dir, ROOT_FILES)
176+
root_files = glob_files(possible_root_dir, ROOT_FILES_DIRS)
177177
logger.debug(f"Root files found: {root_files}")
178178

179179
if root_files:

tests/test_project.py

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@
88
from nitpick.constants import (
99
CONFIG_RUN_NITPICK_INIT_OR_CONFIGURE_STYLE_MANUALLY,
1010
DOT_NITPICK_TOML,
11+
GIT_DIR,
12+
GIT_IGNORE,
1113
GOLANG_MOD,
1214
GOLANG_SUM,
1315
JAVASCRIPT_PACKAGE_JSON,
16+
MAKEFILE,
1417
NITPICK_STYLE_TOML,
1518
PRE_COMMIT_CONFIG_YAML,
1619
PYTHON_MANAGE_PY,
@@ -195,22 +198,27 @@ def test_has_multiple_config_files(tmp_path, caplog):
195198
@pytest.mark.parametrize(
196199
"root_file",
197200
[
198-
DOT_NITPICK_TOML,
199-
PRE_COMMIT_CONFIG_YAML,
200-
PYTHON_PYPROJECT_TOML,
201-
PYTHON_SETUP_PY,
202-
PYTHON_SETUP_CFG,
203-
"requirements.txt",
204-
"requirements_dev.txt",
201+
# keep-sorted start
202+
"Cargo.lock",
203+
"Cargo.toml",
205204
"Pipfile",
206205
"Pipfile.lock",
207-
PYTHON_TOX_INI,
208-
JAVASCRIPT_PACKAGE_JSON,
209-
"Cargo.toml",
210-
"Cargo.lock",
206+
"requirements.txt",
207+
"requirements_dev.txt",
208+
DOT_NITPICK_TOML,
209+
GIT_DIR,
210+
GIT_IGNORE,
211211
GOLANG_MOD,
212212
GOLANG_SUM,
213+
JAVASCRIPT_PACKAGE_JSON,
214+
MAKEFILE,
213215
NITPICK_STYLE_TOML,
216+
PRE_COMMIT_CONFIG_YAML,
217+
PYTHON_PYPROJECT_TOML,
218+
PYTHON_SETUP_CFG,
219+
PYTHON_SETUP_PY,
220+
PYTHON_TOX_INI,
221+
# keep-sorted end
214222
],
215223
)
216224
def test_use_current_dir_dont_climb_dirs_to_find_project_root(tmp_path, root_file):

0 commit comments

Comments
 (0)