mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-07 21:44:18 +00:00
Git pre-commit hook should not check non-python, excluded files
This commit fixes two problems that caused by git pre-commit hook
1. flake8 checks non-python files(.md, .txt, ...) and raise errors
```/var/folders/bb/0_8jdgw15f72f18m_fpqwcqr0000gn/T/tmpqbcrt3vn/Users/Curzy/Workspace/flative/hbnn/hbnn/README.md:3:2:
E999 SyntaxError: invalid syntax
/var/folders/bb/0_8jdgw15f72f18m_fpqwcqr0000gn/T/tmpqbcrt3vn/Users/Curzy/Workspace/flative/hbnn/hbnn/README.md:3:20:
E226 missing whitespace around arithmetic operator```
this problem fixed with find_modified_files function
2. flake8 checks excluded files by config(.flake8, config, ...)
```.flake8
[flake8]
ignore = F401
exclude =
.git,
__pycache__,
hbnn/settings.py,
manage.py,
*/migrations
```
```
./hbnn/settings.py:102:80: E501 line too long (83 > 79 characters)
./user/migrations/0001_initial.py:20:80: E501 line too long (88 > 79 characters)
./user/migrations/0001_initial.py:21:80: E501 line too long (103 > 79 characters)
```
this problem fixed with update_execuldes function should contain both original, temp paths
This commit is contained in:
parent
1a6f8f4169
commit
bfd7092eff
1 changed files with 3 additions and 3 deletions
|
|
@ -153,7 +153,7 @@ def make_temporary_directory_from(destination, directory):
|
||||||
def find_modified_files(lazy):
|
def find_modified_files(lazy):
|
||||||
diff_index_cmd = [
|
diff_index_cmd = [
|
||||||
'git', 'diff-index', '--cached', '--name-only',
|
'git', 'diff-index', '--cached', '--name-only',
|
||||||
'--diff-filter=ACMRTUXB', 'HEAD'
|
'--diff-filter=ACMRTUXB', 'HEAD', '|', 'grep', '-e', '\.py$'
|
||||||
]
|
]
|
||||||
if lazy:
|
if lazy:
|
||||||
diff_index_cmd.remove('--cached')
|
diff_index_cmd.remove('--cached')
|
||||||
|
|
@ -206,10 +206,10 @@ def config_for(parameter):
|
||||||
|
|
||||||
|
|
||||||
def update_excludes(exclude_list, temporary_directory_path):
|
def update_excludes(exclude_list, temporary_directory_path):
|
||||||
return [
|
return exclude_list + [
|
||||||
(temporary_directory_path + pattern)
|
(temporary_directory_path + pattern)
|
||||||
if os.path.isabs(pattern) else pattern
|
|
||||||
for pattern in exclude_list
|
for pattern in exclude_list
|
||||||
|
if os.path.isabs(pattern)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue