Skip to content

Commit aa90b8e

Browse files
committed
ci: disable rule EXE002
It's causing problems for some Windows developers when the repo is checked out on NTFS.
1 parent c9e6ff0 commit aa90b8e

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ repos:
7575
hooks:
7676
- id: flake8
7777
exclude: "^app/core/migrations/|^app/data/migrations/|^app/core/scripts"
78-
args: [--max-line-length=119, --max-complexity=4, --pytest-fixture-no-parentheses]
78+
args: [--max-line-length=119, --max-complexity=4, --pytest-fixture-no-parentheses, --extend-ignore=EXE002]
7979
additional_dependencies:
8080
[
8181
flake8-bugbear,

docs/contributing/tools/pre-commit.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,33 @@ It's recommended to install "global" tools via pipx, which installs packages in
6868
```bash
6969
pre-commit autoupdate
7070
```
71+
72+
## Disabled rules
73+
74+
Sometimes, we need to disable a few specific rules that are causing problems. We list them here along with information about them.
75+
76+
??? info "FLAKE8 EXE002"
77+
78+
This rule is part of flake8's flake8-executable plugin. It checks that all executable scripts have shebangs. This is to ensure that we don't create executable scripts (setting the executable bit) that we don't want to be executable (omitting the shebang).
79+
80+
We disable this rule for the following reasons:
81+
82+
1. The rule is broken for NTFS files.
83+
1. The rule is a duplicate of the `check-executables-have-shebangs` rule in the `pre-commit-hooks` repo.
84+
- that rule [does work with NTFS](https://github.com/pre-commit/pre-commit-hooks/pull/480) by checking the repository metadata for the file, which has the correct executable bit data.
85+
86+
The rule works correctly in these environments:
87+
88+
- Windows (WSL)
89+
- Linux
90+
- macOS
91+
92+
The rule fails under this specific combination of conditions:
93+
94+
1. The developer is on a Windows system.
95+
1. The developer is using git bash.
96+
1. The developer cloned the repository to an NTFS directory (C:\\ or D:) rather than to a linux filesystem (under WSL).
97+
98+
This rule is broken in the following way:
99+
100+
1. It asks the operating system to check if the file is executable and checks the file for a shebang. But NTFS does not have the notion of the executable bit, and will always return `True` for all files. So files like `app/core/admin.py` that's not meant to be executable will look like they are executable, and cause the rule to fail, because it doesn't contain a shebang.

0 commit comments

Comments
 (0)