Skip to content

[BUGS] pre-commit is dependent on a specific environment #38

@bluems

Description

@bluems

Request bug fix

Bug Summary

The vast majority of external Git tools are currently entirely incompatible with pre-commit.
The pre-commit checks are not independent.

Bug status

This has confirmed that the current pre-commit configuration is incompatible with external Git tools that cannot directly activate the virtual environment.
The current pre-commit and various scripts rely heavily on the SYSTEM PATH.
Therefore, pre-commit is incompatible with any system or environment where even one of the following conditions applies:

  • When Python is not present at the system level but is available in a virtual environment
  • When a required package is not installed in the system-level Python
  • When Python exists in a virtual environment but cannot be activated

Most Git tools configure an independent shell environment, so this pre-commit hook may not be compatible:

  • GitKraken
  • Sourcetree
  • Other major Git tools

Program Operating Environment

  • Windows 11

Reference (Optional)

[WARNING] Unstaged files detected.
[INFO] Stashing unstaged files to C:\Users\bsh\.cache\pre-commit\patch1769153287-34176.
[WARNING] hook id `inspect-templates` uses deprecated stage names (commit) which will be removed in a future version.  run: `pre-commit migrate-config` to automatically fix this.
Trim Trailing Whitespace.................................................Passed
Fix End of Files.........................................................Passed
Check Yaml...........................................(no files to check)Skipped
Check Toml...............................................................Passed
format...................................................................Failed
- hook id: format
- exit code: 127

+++ dirname scripts/format.sh                                                                                        209Z-debug-0.log
++ dirname scripts
+ base_dir=.
+ black --config ./pyproject.toml --check .
scripts/format.sh: line 7: black: command not found
+ black --config ./pyproject.toml .
scripts/format.sh: line 8: black: command not found

lint.....................................................................Failed
- hook id: lint
- exit code: 127

+++ dirname scripts/lint.sh
++ dirname scripts
+ base_dir=.
+ isort --sp ./pyproject.toml --check .
scripts/lint.sh: line 7: isort: command not found
+ isort --sp ./pyproject.toml .
scripts/lint.sh: line 8: isort: command not found
+ black --config ./pyproject.toml .
scripts/lint.sh: line 9: black: command not found
+ mypy --config-file ./pyproject.toml src
scripts/lint.sh: line 11: mypy: command not found

coverage test........................................(no files to check)Skipped
inspect changed fastapi templates........................................Failed
- hook id: inspect-templates
- exit code: 1

Traceback (most recent call last):
  File "D:\my_projects\FastAPI-fastkit\scripts\inspect-changed-templates.py", line 15, in <module>
    from fastapi_fastkit.backend.inspector import inspect_fastapi_template
  File "D:\my_projects\FastAPI-fastkit\src\fastapi_fastkit\backend\inspector.py", line 31, in <module>
    from fastapi_fastkit.backend.main import (
  File "D:\my_projects\FastAPI-fastkit\src\fastapi_fastkit\backend\main.py", line 12, in <module>
    from fastapi_fastkit.backend.package_managers import PackageManagerFactory
  File "D:\my_projects\FastAPI-fastkit\src\fastapi_fastkit\backend\package_managers\__init__.py", line 9, in <module>    from .factory import PackageManagerFactory
  File "D:\my_projects\FastAPI-fastkit\src\fastapi_fastkit\backend\package_managers\factory.py", line 9, in <module> 
    from fastapi_fastkit.utils.logging import debug_log, get_logger
  File "D:\my_projects\FastAPI-fastkit\src\fastapi_fastkit\utils\logging.py", line 16, in <module>
    from rich.console import Console
ModuleNotFoundError: No module named 'rich'

[INFO] Restored changes from C:\Users\bsh\.cache\pre-commit\patch1769153287-34176.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingdependenciesPull requests that update a dependency filefixFix or improve source codesgood first issueGood for newcomers

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions