Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flake8-django doesn't report error if flake8 was ran under pre-commit #118

Open
BigDeepBlue opened this issue May 27, 2023 · 3 comments
Open

Comments

@BigDeepBlue
Copy link

I stuck with the issue that if I run flake8 admin.py manually - I see error DJ07, but when I try to do that in pre-commit hook, check passes silently. So.

Python 3.9.16 (main, Mar 10 2023, 13:37:42)
[Clang 14.0.0 (clang-1400.0.29.202)] on darwin

admin.py

import locale
import calendar

from django import forms
from django.contrib import admin



def check_bb(default=[]):
    default.append(1)
    return default


class SomeForm(forms.ModelForm):
    class Meta:
        model = SomeHistory
        fields = "__all__"



pyproject.toml

[tool.black]
target-version = ["py39"]
force-exclude = "/(scripts|migrations|jenkinsfiles|doc|docs)/"
line-length = 119
verbose = "false"

[tool.flake8]
ignore = ["E501", "E265", "F811", "BLK100", "T003", "E722", "E722", "W503", "E203"]
max-line-length = 119
inline-quotes = "double"
exclude = [
  "static",
  "migrations",
  "*/migrations/*",
  ".git",
  "__pycache__",
  "venv",
  ".venv",
  "env",
]

.pre-commit-config.yaml

default_language_version:
  python: python3.9

fail_fast: true

repos:
  - repo: https://github.com/pycqa/flake8.git
    rev: 6.0.0
    hooks:
      - id: flake8
        name: flake8 (python)
        entry: flake8 -vv
        verbose: true
        description: flake8 checker
        types: [python]
        language: python

        additional_dependencies: [
          flake8-pyproject==1.2.3,
          flake8-django==1.3,
          flake8-black==0.3.6,
          flake8-bugbear==23.5.9,
          flake8-builtins==2.1.0,
          flake8-isort==6.0.0,
          flake8-plugin-utils==1.3.2,
          flake8-polyfill==1.0.2,
          flake8-print==5.0.0,
          flake8-pytest==1.4,
          flake8-pytest-style==1.6.0,
          flake8-quotes==3.3.2,
          flake8-tidy-imports==4.8.0,
          flake8-typing-imports==1.14.0
        ]


requirements.txt

Django==3.2

# linters
pre-commit==3.3.2
black==23.3.0
isort==5.12.0

flake8==6.0.0
flake8-pyproject==1.2.3
flake8-black==0.3.6
flake8-bugbear==23.5.9
flake8-builtins==2.1.0
flake8-django==1.3
flake8-isort==6.0.0
flake8-plugin-utils==1.3.2
flake8-polyfill==1.0.2
flake8-print==5.0.0
flake8-pytest==1.4
flake8-pytest-style==1.6.0
flake8-quotes==3.3.2
flake8-tidy-imports==4.8.0

so when I created virtualenv and install there deps from requirements.txt, then I ran

(pre) ➜  pre-comm git:(master) ✗ flake8 -vv admin.py 
flake8                    MainProcess     25 DEBUG    Added a None logging handler to logger root at flake8
flake8.options.manager    MainProcess    229 DEBUG    Registered option "Option(-q, --quiet, action='count', default=0, help='Report only file names, or nothing. This option is repeatable.')".
flake8.options.manager    MainProcess    229 DEBUG    Registered option "Option(--color, default='auto', choices=('auto', 'always', 'never'), help='Whether to use color in output.  Defaults to `%(default)s`.')".
flake8.options.manager    MainProcess    229 DEBUG    Registered option "Option(--count, action='store_true', help='Print total number of errors to standard output after all other output.')".
flake8.options.manager    MainProcess    229 DEBUG    Registered option "Option(--exclude, default='.svn,CVS,.bzr,.hg,.git,__pycache__,.tox,.nox,.eggs,*.egg', type=functools.partial(<function _flake8_normalize at 0x1057c1430>, comma_separated_list=True, normalize_paths=True), help='Comma-separated list of files or directories to exclude. (Default: %(default)s)', metavar='patterns')".
flake8.options.manager    MainProcess    229 DEBUG    Registered option "Option(--extend-exclude, default='', type=functools.partial(<function _flake8_normalize at 0x1057c1430>, comma_separated_list=True, normalize_paths=True), help='Comma-separated list of files or directories to add to the list of excluded ones.', metavar='patterns')".
flake8.options.manager    MainProcess    229 DEBUG    Registered option "Option(--filename, default='*.py', type=functools.partial(<function _flake8_normalize at 0x1057c1430>, comma_separated_list=True, normalize_paths=False), help='Only check for filenames matching the patterns in this comma-separated list. (Default: %(default)s)', metavar='patterns')".
flake8.options.manager    MainProcess    229 DEBUG    Registered option "Option(--stdin-display-name, default='stdin', help='The name used when reporting errors from code passed via stdin. This is useful for editors piping the file contents to flake8. (Default: %(default)s)')".
flake8.options.manager    MainProcess    229 DEBUG    Registered option "Option(--format, default='default', help="Format errors according to the chosen formatter (Flake8-pyproject, default, pylint, quiet-filename, quiet-nothing) or a format string containing %%-style mapping keys (code, col, path, row, text). For example, ``--format=pylint`` or ``--format='%%(path)s %%(code)s'``. (Default: %(default)s)", metavar='format')".
flake8.options.manager    MainProcess    229 DEBUG    Registered option "Option(--hang-closing, action='store_true', help="Hang closing bracket instead of matching indentation of opening bracket's line.")".
flake8.options.manager    MainProcess    229 DEBUG    Registered option "Option(--ignore, type=functools.partial(<function _flake8_normalize at 0x1057c1430>, comma_separated_list=True, normalize_paths=False), help='Comma-separated list of error codes to ignore (or skip). For example, ``--ignore=E4,E51,W234``. (Default: E121,E123,E126,E226,E24,E704,W503,W504)', metavar='errors')".
flake8.options.manager    MainProcess    229 DEBUG    Registered option "Option(--extend-ignore, type=functools.partial(<function _flake8_normalize at 0x1057c1430>, comma_separated_list=True, normalize_paths=False), help='Comma-separated list of error codes to add to the list of ignored ones. For example, ``--extend-ignore=E4,E51,W234``.', metavar='errors')".
flake8.options.manager    MainProcess    229 DEBUG    Registered option "Option(--per-file-ignores, default='', help='A pairing of filenames and violation codes that defines which violations to ignore in a particular file. The filenames can be specified in a manner similar to the ``--exclude`` option and the violations work similarly to the ``--ignore`` and ``--select`` options.')".
flake8.options.manager    MainProcess    230 DEBUG    Registered option "Option(--max-line-length, default=79, type=<class 'int'>, help='Maximum allowed line length for the entirety of this run. (Default: %(default)s)', metavar='n')".
flake8.options.manager    MainProcess    230 DEBUG    Registered option "Option(--max-doc-length, default=None, type=<class 'int'>, help='Maximum allowed doc line length for the entirety of this run. (Default: %(default)s)', metavar='n')".
flake8.options.manager    MainProcess    230 DEBUG    Registered option "Option(--indent-size, default=4, type=<class 'int'>, help='Number of spaces used for indentation (Default: %(default)s)', metavar='n')".
flake8.options.manager    MainProcess    230 DEBUG    Registered option "Option(--select, type=functools.partial(<function _flake8_normalize at 0x1057c1430>, comma_separated_list=True, normalize_paths=False), help='Comma-separated list of error codes to enable. For example, ``--select=E4,E51,W234``. (Default: E,F,W,C90)', metavar='errors')".
flake8.options.manager    MainProcess    230 DEBUG    Registered option "Option(--extend-select, type=functools.partial(<function _flake8_normalize at 0x1057c1430>, comma_separated_list=True, normalize_paths=False), help='Comma-separated list of error codes to add to the list of selected ones. For example, ``--extend-select=E4,E51,W234``.', metavar='errors')".
flake8.options.manager    MainProcess    230 DEBUG    Registered option "Option(--disable-noqa, action='store_true', default=False, help='Disable the effect of "# noqa". This will report errors on lines with "# noqa" at the end.')".
flake8.options.manager    MainProcess    230 DEBUG    Registered option "Option(--show-source, action='store_true', help='Show the source generate each error or warning.')".
flake8.options.manager    MainProcess    230 DEBUG    Registered option "Option(--no-show-source, action='store_false', dest='show_source', help='Negate --show-source')".
flake8.options.manager    MainProcess    230 DEBUG    Registered option "Option(--statistics, action='store_true', help='Count errors.')".
flake8.options.manager    MainProcess    230 DEBUG    Registered option "Option(--exit-zero, action='store_true', help='Exit with status code "0" even if there are errors.')".
flake8.options.manager    MainProcess    230 DEBUG    Registered option "Option(-j, --jobs, default='auto', type=<class 'flake8.main.options.JobsArgument'>, help='Number of subprocesses to use to run checks in parallel. This is ignored on Windows. The default, "auto", will auto-detect the number of processors available to use. (Default: %(default)s)')".
flake8.options.manager    MainProcess    230 DEBUG    Registered option "Option(--tee, action='store_true', default=False, help='Write to stdout and output-file.')".
flake8.options.manager    MainProcess    230 DEBUG    Registered option "Option(--benchmark, action='store_true', default=False, help='Print benchmark information about this run of Flake8')".
flake8.options.manager    MainProcess    230 DEBUG    Registered option "Option(--bug-report, action='store_true', help='Print information necessary when preparing a bug report')".
flake8.options.manager    MainProcess    230 DEBUG    Registered option "Option(--black-config, action='store', default=None, help="Path to black TOML configuration file (overrides the default 'pyproject.toml' detection; use empty string '' to mean ignore all 'pyproject.toml' files).", metavar='TOML_FILENAME')".
flake8.options.manager    MainProcess    230 DEBUG    Extending default select list with ['BLK']
flake8.options.manager    MainProcess    230 DEBUG    Extending default ignore list with ['B901', 'B902', 'B903', 'B904', 'B905', 'B906', 'B908', 'B950']
flake8.options.manager    MainProcess    230 DEBUG    Registered option "Option(--extend-immutable-calls, default=[], type=functools.partial(<function _flake8_normalize at 0x1057c1430>, comma_separated_list=True, normalize_paths=False), help='Skip B008 test for additional immutable calls.')".
flake8.options.manager    MainProcess    231 DEBUG    Extending default select list with ['B']
flake8.options.manager    MainProcess    231 DEBUG    Registered option "Option(--builtins-ignorelist, type=functools.partial(<function _flake8_normalize at 0x1057c1430>, comma_separated_list=True, normalize_paths=False), help='A comma separated list of builtins to skip checking', metavar='builtins')".
flake8.options.manager    MainProcess    231 DEBUG    Extending default select list with ['A00']
flake8.options.manager    MainProcess    231 DEBUG    Extending default ignore list with ['DJ10', 'DJ11']
flake8.options.manager    MainProcess    231 DEBUG    Extending default select list with ['DJ']
flake8.options.manager    MainProcess    231 DEBUG    Registered option "Option(--isort-show-traceback, action='store_true', help='Show full traceback with diff from isort')".
flake8.options.manager    MainProcess    231 DEBUG    Registered option "Option(--isort-no-skip-gitignore, action='store_true', help="Temporarily override the set value of isort's `skip_gitignore` option with `False`. This can cause flake8-isort to run significantly faster at the cost of making flake8-isort's behavior differ slightly from the behavior of `isort --check`.")".
flake8.options.manager    MainProcess    231 DEBUG    Extending default select list with ['I00']
flake8.options.manager    MainProcess    231 DEBUG    Extending default select list with ['T20']
flake8.options.manager    MainProcess    231 DEBUG    Extending default select list with ['T']
flake8.options.manager    MainProcess    231 DEBUG    Registered option "Option(--pytest-fixture-no-parentheses, action='store_true', default=False, help='Omit parentheses for @pytest.fixture decorators without parameters. (Default: %(default)s)')".
flake8.options.manager    MainProcess    231 DEBUG    Registered option "Option(--pytest-raises-require-match-for, default=['BaseException', 'Exception', 'ValueError', 'IOError', 'OSError', 'EnvironmentError', 'socket.error'], type=functools.partial(<function _flake8_normalize at 0x1057c1430>, comma_separated_list=True, normalize_paths=False), help='List of exceptions for which flake8-pytest-style requires a match= argument in pytest.raises(). (Default: %(default)s)')".
flake8.options.manager    MainProcess    231 DEBUG    Registered option "Option(--pytest-parametrize-names-type, default='tuple', choices=['csv', 'tuple', 'list'], help='Preferred type for multiple parameter names in @pytest.mark.parametrize. (Default: %(default)s)')".
flake8.options.manager    MainProcess    231 DEBUG    Registered option "Option(--pytest-parametrize-values-type, default='list', choices=['tuple', 'list'], help='Preferred type for values in @pytest.mark.parametrize. (Default: %(default)s)')".
flake8.options.manager    MainProcess    231 DEBUG    Registered option "Option(--pytest-parametrize-values-row-type, default='tuple', choices=['tuple', 'list'], help='Preferred type for each row in @pytest.mark.parametrize in case of multiple parameters. (Default: %(default)s)')".
flake8.options.manager    MainProcess    231 DEBUG    Registered option "Option(--pytest-mark-no-parentheses, action='store_true', default=False, help='Omit parentheses for @pytest.mark.foo decorators without parameters. (Default: %(default)s)')".
flake8.options.manager    MainProcess    231 DEBUG    Extending default select list with ['PT']
flake8.options.manager    MainProcess    231 DEBUG    Registered option "Option(--quotes, action='store', choices=['"', "'", 'double', 'single'], help='Deprecated alias for `--inline-quotes`')".
flake8.options.manager    MainProcess    231 DEBUG    Registered option "Option(--inline-quotes, action='store', default="'", choices=['"', "'", 'double', 'single'], help="Quote to expect in all files (default: ')")".
flake8.options.manager    MainProcess    231 DEBUG    Registered option "Option(--multiline-quotes, action='store', default=None, choices=['"', '"""', "'", "'''", 'double', 'single'], help='Quote to expect in all files (default: """)')".
flake8.options.manager    MainProcess    232 DEBUG    Registered option "Option(--docstring-quotes, action='store', default=None, choices=['"', '"""', "'", "'''", 'double', 'single'], help='Quote to expect in all files (default: """)')".
flake8.options.manager    MainProcess    232 DEBUG    Registered option "Option(--avoid-escape, action='store_true', default=None, help='Avoiding escaping same quotes in inline strings (enabled by default)')".
flake8.options.manager    MainProcess    232 DEBUG    Registered option "Option(--no-avoid-escape, action='store_false', default=None, dest='avoid_escape', help='Disable avoiding escaping same quotes in inline strings')".
flake8.options.manager    MainProcess    232 DEBUG    Extending default select list with ['Q0']
flake8.options.manager    MainProcess    232 DEBUG    Registered option "Option(--banned-modules, action='store', default='', help='A map of modules to ban to the error messages to display in the error.')".
flake8.options.manager    MainProcess    232 DEBUG    Registered option "Option(--ban-relative-imports, action='store', default='', nargs='?', const='true', choices=['', 'parents', 'true'], help='Ban relative imports, from parental modules or in all cases.')".
flake8.options.manager    MainProcess    232 DEBUG    Extending default select list with ['I25']
flake8.options.manager    MainProcess    232 DEBUG    Registered option "Option(--max-complexity, action='store', default=-1, type=<class 'int'>, help='McCabe complexity threshold')".
flake8.options.manager    MainProcess    232 DEBUG    Extending default select list with ['C90']
flake8.options.manager    MainProcess    232 DEBUG    Registered option "Option(--builtins, type=functools.partial(<function _flake8_normalize at 0x1057c1430>, comma_separated_list=True, normalize_paths=False), help='define more built-ins, comma separated')".
flake8.options.manager    MainProcess    232 DEBUG    Registered option "Option(--doctests, action='store_true', default=False, help='also check syntax of the doctests')".
flake8.options.manager    MainProcess    232 DEBUG    Registered option "Option(--include-in-doctest, default='', type=functools.partial(<function _flake8_normalize at 0x1057c1430>, comma_separated_list=True, normalize_paths=True), dest='include_in_doctest', help='Run doctests only on these files')".
flake8.options.manager    MainProcess    232 DEBUG    Registered option "Option(--exclude-from-doctest, default='', type=functools.partial(<function _flake8_normalize at 0x1057c1430>, comma_separated_list=True, normalize_paths=True), dest='exclude_from_doctest', help='Skip these files when running doctests')".
flake8.options.manager    MainProcess    232 DEBUG    Extending default select list with ['F']
flake8.options.manager    MainProcess    232 DEBUG    Extending default select list with ['E']
flake8.options.manager    MainProcess    232 DEBUG    Extending default select list with ['W']
flake8.options.manager    MainProcess    232 DEBUG    Registered option "Option(--toml-config, action='store', default=None, help='Path to custom TOML configuration file. May be located in a different folder. Overrides the default "pyproject.toml" in the current working directory.', metavar='TOML_COMFIG')".
flake8.options.config     MainProcess    233 DEBUG    Option "ignore" returned value: ['E501', 'E265', 'F811', 'BLK100', 'T003', 'E722', 'E722', 'W503', 'E203']
flake8.options.config     MainProcess    233 DEBUG    Option "max-line-length" returned value: 119
flake8.options.config     MainProcess    233 DEBUG    Option "inline-quotes" returned value: 'double'
flake8.options.config     MainProcess    233 DEBUG    Option "exclude" returned value: ['static', 'migrations', '*/migrations/*', '.git', '__pycache__', 'venv', '.venv', 'env']
flake8.options.aggregator MainProcess    233 DEBUG    Overriding default value of (None) for "ignore" with (['E501', 'E265', 'F811', 'BLK100', 'T003', 'E722', 'E722', 'W503', 'E203'])
flake8.options.aggregator MainProcess    233 DEBUG    Overriding default value of (79) for "max_line_length" with (119)
flake8.options.aggregator MainProcess    233 DEBUG    Overriding default value of (') for "inline_quotes" with (double)
flake8.options.aggregator MainProcess    233 DEBUG    Overriding default value of (['.svn', 'CVS', '.bzr', '.hg', '.git', '__pycache__', '.tox', '.nox', '.eggs', '*.egg']) for "exclude" with (['static', 'migrations', '/Users/matrix/work/pre-comm/*/migrations/*', '.git', '__pycache__', 'venv', '.venv', 'env'])
flake8                    MainProcess    233 INFO     flake8-black: No black configuration set
flake8.checker            MainProcess    233 INFO     Making checkers
flake8.discover_files     MainProcess    234 DEBUG    "/Users/matrix/work/pre-comm/admin.py" has not been excluded
flake8                    MainProcess    235 INFO     flake8-black: loading black settings from /Users/matrix/work/pre-comm/pyproject.toml
flake8                    MainProcess    235 DEBUG    flake8-black: admin.py using newly loaded /Users/matrix/work/pre-comm/pyproject.toml
flake8.processor          MainProcess    460 WARNING  Plugin requested optional parameter "builtins" but this is not an available parameter.
flake8.checker            MainProcess    461 DEBUG    Logical line: "import locale"
flake8.checker            MainProcess    461 DEBUG    Logical line: "import calendar"
flake8.checker            MainProcess    461 DEBUG    Logical line: "from django import forms"
flake8.checker            MainProcess    462 DEBUG    Logical line: "from django.contrib import admin"
flake8.checker            MainProcess    462 DEBUG    Logical line: "def check_bb(default=[]):"
flake8.checker            MainProcess    462 DEBUG    Logical line: "default.append(1)"
flake8.checker            MainProcess    462 DEBUG    Logical line: "return default"
flake8.checker            MainProcess    462 DEBUG    Logical line: "class SomeForm(forms.ModelForm):"
flake8.checker            MainProcess    462 DEBUG    Logical line: "class Meta:"
flake8.checker            MainProcess    462 DEBUG    Logical line: "model = SomeHistory"
flake8.checker            MainProcess    462 DEBUG    Logical line: "fields = "xxxxxxx""
flake8.main.application   MainProcess    462 INFO     Finished running
flake8.main.application   MainProcess    462 INFO     Reporting errors
flake8.style_guide        MainProcess    462 DEBUG    The user configured 'F401' to be <Selected.Implicitly: 'implicitly selected'>, <Selected.Implicitly: 'implicitly selected'>
flake8.style_guide        MainProcess    462 DEBUG    "F401" will be "Decision.Selected"
flake8.violation          MainProcess    462 DEBUG    Violation(code='F401', filename='admin.py', line_number=1, column_number=1, text="'locale' imported but unused", physical_line='import locale\n') is not inline ignored
flake8.style_guide        MainProcess    462 DEBUG    The user configured 'I001' to be <Selected.Implicitly: 'implicitly selected'>, <Selected.Implicitly: 'implicitly selected'>
flake8.style_guide        MainProcess    462 DEBUG    "I001" will be "Decision.Selected"
flake8.violation          MainProcess    462 DEBUG    Violation(code='I001', filename='admin.py', line_number=2, column_number=1, text='isort found an import in the wrong position', physical_line='import calendar\n') is not inline ignored
flake8.violation          MainProcess    462 DEBUG    Violation(code='F401', filename='admin.py', line_number=2, column_number=1, text="'calendar' imported but unused", physical_line='import calendar\n') is not inline ignored
flake8.violation          MainProcess    462 DEBUG    Violation(code='F401', filename='admin.py', line_number=5, column_number=1, text="'django.contrib.admin' imported but unused", physical_line='from django.contrib import admin\n') is not inline ignored
flake8.style_guide        MainProcess    462 DEBUG    The user configured 'I004' to be <Selected.Implicitly: 'implicitly selected'>, <Selected.Implicitly: 'implicitly selected'>
flake8.style_guide        MainProcess    463 DEBUG    "I004" will be "Decision.Selected"
flake8.violation          MainProcess    463 DEBUG    Violation(code='I004', filename='admin.py', line_number=6, column_number=1, text='isort found an unexpected blank line in imports', physical_line='\n') is not inline ignored
flake8.violation          MainProcess    463 DEBUG    Violation(code='I004', filename='admin.py', line_number=7, column_number=1, text='isort found an unexpected blank line in imports', physical_line='\n') is not inline ignored
flake8.style_guide        MainProcess    463 DEBUG    The user configured 'BLK100' to be <Selected.Implicitly: 'implicitly selected'>, <Ignored.Explicitly: 'explicitly ignored'>
flake8.style_guide        MainProcess    463 DEBUG    "BLK100" will be "Decision.Ignored"
flake8.violation          MainProcess    463 DEBUG    Violation(code='BLK100', filename='admin.py', line_number=8, column_number=1, text='Black would make changes.', physical_line='\n') is not inline ignored
flake8.style_guide        MainProcess    463 DEBUG    The user configured 'E303' to be <Selected.Implicitly: 'implicitly selected'>, <Selected.Implicitly: 'implicitly selected'>
flake8.style_guide        MainProcess    463 DEBUG    "E303" will be "Decision.Selected"
flake8.violation          MainProcess    463 DEBUG    Violation(code='E303', filename='admin.py', line_number=10, column_number=1, text='too many blank lines (4)', physical_line='def check_bb(default=[]):\n') is not inline ignored
flake8.style_guide        MainProcess    463 DEBUG    The user configured 'B006' to be <Selected.Implicitly: 'implicitly selected'>, <Selected.Implicitly: 'implicitly selected'>
flake8.style_guide        MainProcess    463 DEBUG    "B006" will be "Decision.Selected"
flake8.violation          MainProcess    463 DEBUG    Violation(code='B006', filename='admin.py', line_number=10, column_number=22, text='Do not use mutable data structures for argument defaults.  They are created during function definition time. All calls to the function reuse this one instance of that data structure, persisting changes between them.', physical_line='def check_bb(default=[]):\n') is not inline ignored
flake8.style_guide        MainProcess    463 DEBUG    The user configured 'DJ07' to be <Selected.Implicitly: 'implicitly selected'>, <Selected.Implicitly: 'implicitly selected'>
flake8.style_guide        MainProcess    463 DEBUG    "DJ07" will be "Decision.Selected"
flake8.violation          MainProcess    463 DEBUG    Violation(code='DJ07', filename='admin.py', line_number=15, column_number=1, text='Do not use __all__ with ModelForm, use fields instead', physical_line='class SomeForm(forms.ModelForm):\n') is not inline ignored
flake8.style_guide        MainProcess    463 DEBUG    The user configured 'F821' to be <Selected.Implicitly: 'implicitly selected'>, <Selected.Implicitly: 'implicitly selected'>
flake8.style_guide        MainProcess    463 DEBUG    "F821" will be "Decision.Selected"
flake8.violation          MainProcess    463 DEBUG    Violation(code='F821', filename='admin.py', line_number=17, column_number=17, text="undefined name 'SomeHistory'", physical_line='        model = SomeHistory\n') is not inline ignored
flake8.style_guide        MainProcess    463 DEBUG    The user configured 'W391' to be <Selected.Implicitly: 'implicitly selected'>, <Selected.Implicitly: 'implicitly selected'>
flake8.style_guide        MainProcess    463 DEBUG    "W391" will be "Decision.Selected"
flake8.violation          MainProcess    463 DEBUG    Violation(code='W391', filename='admin.py', line_number=20, column_number=1, text='blank line at end of file', physical_line='\n') is not inline ignored
flake8.main.application   MainProcess    463 INFO     Found a total of 12 violations and reported 11
admin.py:1:1: F401 'locale' imported but unused
admin.py:2:1: I001 isort found an import in the wrong position
admin.py:2:1: F401 'calendar' imported but unused
admin.py:5:1: F401 'django.contrib.admin' imported but unused
admin.py:6:1: I004 isort found an unexpected blank line in imports
admin.py:7:1: I004 isort found an unexpected blank line in imports
admin.py:10:1: E303 too many blank lines (4)
admin.py:10:22: B006 Do not use mutable data structures for argument defaults.  They are created during function definition time. All calls to the function reuse this one instance of that data structure, persisting changes between them.
admin.py:15:1: DJ07 Do not use __all__ with ModelForm, use fields instead
admin.py:17:17: F821 undefined name 'SomeHistory'
admin.py:20:1: W391 blank line at end of file

So here I can see error from your plugin, well

admin.py:15:1: DJ07 Do not use __all__ with ModelForm, use fields instead
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  

Then if I do git add admin.py then run

(pre) ➜  pre-comm git:(master) ✗ pre-commit run
[WARNING] Unstaged files detected.
[INFO] Stashing unstaged files to /Users/matrix/.cache/pre-commit/patch1685174608-74498.
flake8 (python)..........................................................Failed
- hook id: flake8
- duration: 0.36s
- exit code: 1

flake8                    MainProcess     31 DEBUG    Added a None logging handler to logger root at flake8
flake8.options.manager    MainProcess    260 DEBUG    Registered option "Option(-q, --quiet, action='count', default=0, help='Report only file names, or nothing. This option is repeatable.')".
flake8.options.manager    MainProcess    260 DEBUG    Registered option "Option(--color, default='auto', choices=('auto', 'always', 'never'), help='Whether to use color in output.  Defaults to `%(default)s`.')".
flake8.options.manager    MainProcess    260 DEBUG    Registered option "Option(--count, action='store_true', help='Print total number of errors to standard output after all other output.')".
flake8.options.manager    MainProcess    260 DEBUG    Registered option "Option(--exclude, default='.svn,CVS,.bzr,.hg,.git,__pycache__,.tox,.nox,.eggs,*.egg', type=functools.partial(<function _flake8_normalize at 0x100f82940>, comma_separated_list=True, normalize_paths=True), help='Comma-separated list of files or directories to exclude. (Default: %(default)s)', metavar='patterns')".
flake8.options.manager    MainProcess    260 DEBUG    Registered option "Option(--extend-exclude, default='', type=functools.partial(<function _flake8_normalize at 0x100f82940>, comma_separated_list=True, normalize_paths=True), help='Comma-separated list of files or directories to add to the list of excluded ones.', metavar='patterns')".
flake8.options.manager    MainProcess    260 DEBUG    Registered option "Option(--filename, default='*.py', type=functools.partial(<function _flake8_normalize at 0x100f82940>, comma_separated_list=True, normalize_paths=False), help='Only check for filenames matching the patterns in this comma-separated list. (Default: %(default)s)', metavar='patterns')".
flake8.options.manager    MainProcess    260 DEBUG    Registered option "Option(--stdin-display-name, default='stdin', help='The name used when reporting errors from code passed via stdin. This is useful for editors piping the file contents to flake8. (Default: %(default)s)')".
flake8.options.manager    MainProcess    260 DEBUG    Registered option "Option(--format, default='default', help="Format errors according to the chosen formatter (Flake8-pyproject, default, pylint, quiet-filename, quiet-nothing) or a format string containing %%-style mapping keys (code, col, path, row, text). For example, ``--format=pylint`` or ``--format='%%(path)s %%(code)s'``. (Default: %(default)s)", metavar='format')".
flake8.options.manager    MainProcess    260 DEBUG    Registered option "Option(--hang-closing, action='store_true', help="Hang closing bracket instead of matching indentation of opening bracket's line.")".
flake8.options.manager    MainProcess    260 DEBUG    Registered option "Option(--ignore, type=functools.partial(<function _flake8_normalize at 0x100f82940>, comma_separated_list=True, normalize_paths=False), help='Comma-separated list of error codes to ignore (or skip). For example, ``--ignore=E4,E51,W234``. (Default: E121,E123,E126,E226,E24,E704,W503,W504)', metavar='errors')".
flake8.options.manager    MainProcess    260 DEBUG    Registered option "Option(--extend-ignore, type=functools.partial(<function _flake8_normalize at 0x100f82940>, comma_separated_list=True, normalize_paths=False), help='Comma-separated list of error codes to add to the list of ignored ones. For example, ``--extend-ignore=E4,E51,W234``.', metavar='errors')".
flake8.options.manager    MainProcess    260 DEBUG    Registered option "Option(--per-file-ignores, default='', help='A pairing of filenames and violation codes that defines which violations to ignore in a particular file. The filenames can be specified in a manner similar to the ``--exclude`` option and the violations work similarly to the ``--ignore`` and ``--select`` options.')".
flake8.options.manager    MainProcess    260 DEBUG    Registered option "Option(--max-line-length, default=79, type=<class 'int'>, help='Maximum allowed line length for the entirety of this run. (Default: %(default)s)', metavar='n')".
flake8.options.manager    MainProcess    260 DEBUG    Registered option "Option(--max-doc-length, default=None, type=<class 'int'>, help='Maximum allowed doc line length for the entirety of this run. (Default: %(default)s)', metavar='n')".
flake8.options.manager    MainProcess    260 DEBUG    Registered option "Option(--indent-size, default=4, type=<class 'int'>, help='Number of spaces used for indentation (Default: %(default)s)', metavar='n')".
flake8.options.manager    MainProcess    261 DEBUG    Registered option "Option(--select, type=functools.partial(<function _flake8_normalize at 0x100f82940>, comma_separated_list=True, normalize_paths=False), help='Comma-separated list of error codes to enable. For example, ``--select=E4,E51,W234``. (Default: E,F,W,C90)', metavar='errors')".
flake8.options.manager    MainProcess    261 DEBUG    Registered option "Option(--extend-select, type=functools.partial(<function _flake8_normalize at 0x100f82940>, comma_separated_list=True, normalize_paths=False), help='Comma-separated list of error codes to add to the list of selected ones. For example, ``--extend-select=E4,E51,W234``.', metavar='errors')".
flake8.options.manager    MainProcess    261 DEBUG    Registered option "Option(--disable-noqa, action='store_true', default=False, help='Disable the effect of "# noqa". This will report errors on lines with "# noqa" at the end.')".
flake8.options.manager    MainProcess    261 DEBUG    Registered option "Option(--show-source, action='store_true', help='Show the source generate each error or warning.')".
flake8.options.manager    MainProcess    261 DEBUG    Registered option "Option(--no-show-source, action='store_false', dest='show_source', help='Negate --show-source')".
flake8.options.manager    MainProcess    261 DEBUG    Registered option "Option(--statistics, action='store_true', help='Count errors.')".
flake8.options.manager    MainProcess    261 DEBUG    Registered option "Option(--exit-zero, action='store_true', help='Exit with status code "0" even if there are errors.')".
flake8.options.manager    MainProcess    261 DEBUG    Registered option "Option(-j, --jobs, default='auto', type=<class 'flake8.main.options.JobsArgument'>, help='Number of subprocesses to use to run checks in parallel. This is ignored on Windows. The default, "auto", will auto-detect the number of processors available to use. (Default: %(default)s)')".
flake8.options.manager    MainProcess    261 DEBUG    Registered option "Option(--tee, action='store_true', default=False, help='Write to stdout and output-file.')".
flake8.options.manager    MainProcess    261 DEBUG    Registered option "Option(--benchmark, action='store_true', default=False, help='Print benchmark information about this run of Flake8')".
flake8.options.manager    MainProcess    261 DEBUG    Registered option "Option(--bug-report, action='store_true', help='Print information necessary when preparing a bug report')".
flake8.options.manager    MainProcess    261 DEBUG    Registered option "Option(--black-config, action='store', default=None, help="Path to black TOML configuration file (overrides the default 'pyproject.toml' detection; use empty string '' to mean ignore all 'pyproject.toml' files).", metavar='TOML_FILENAME')".
flake8.options.manager    MainProcess    261 DEBUG    Extending default select list with ['BLK']
flake8.options.manager    MainProcess    261 DEBUG    Extending default ignore list with ['B901', 'B902', 'B903', 'B904', 'B905', 'B906', 'B908', 'B950']
flake8.options.manager    MainProcess    261 DEBUG    Registered option "Option(--extend-immutable-calls, default=[], type=functools.partial(<function _flake8_normalize at 0x100f82940>, comma_separated_list=True, normalize_paths=False), help='Skip B008 test for additional immutable calls.')".
flake8.options.manager    MainProcess    261 DEBUG    Extending default select list with ['B']
flake8.options.manager    MainProcess    261 DEBUG    Registered option "Option(--builtins-ignorelist, type=functools.partial(<function _flake8_normalize at 0x100f82940>, comma_separated_list=True, normalize_paths=False), help='A comma separated list of builtins to skip checking', metavar='builtins')".
flake8.options.manager    MainProcess    261 DEBUG    Extending default select list with ['A00']
flake8.options.manager    MainProcess    261 DEBUG    Extending default ignore list with ['DJ10', 'DJ11']
flake8.options.manager    MainProcess    261 DEBUG    Extending default select list with ['DJ']
flake8.options.manager    MainProcess    261 DEBUG    Registered option "Option(--isort-show-traceback, action='store_true', help='Show full traceback with diff from isort')".
flake8.options.manager    MainProcess    261 DEBUG    Registered option "Option(--isort-no-skip-gitignore, action='store_true', help="Temporarily override the set value of isort's `skip_gitignore` option with `False`. This can cause flake8-isort to run significantly faster at the cost of making flake8-isort's behavior differ slightly from the behavior of `isort --check`.")".
flake8.options.manager    MainProcess    261 DEBUG    Extending default select list with ['I00']
flake8.options.manager    MainProcess    261 DEBUG    Extending default select list with ['T20']
flake8.options.manager    MainProcess    261 DEBUG    Extending default select list with ['T']
flake8.options.manager    MainProcess    261 DEBUG    Registered option "Option(--pytest-fixture-no-parentheses, action='store_true', default=False, help='Omit parentheses for @pytest.fixture decorators without parameters. (Default: %(default)s)')".
flake8.options.manager    MainProcess    261 DEBUG    Registered option "Option(--pytest-raises-require-match-for, default=['BaseException', 'Exception', 'ValueError', 'IOError', 'OSError', 'EnvironmentError', 'socket.error'], type=functools.partial(<function _flake8_normalize at 0x100f82940>, comma_separated_list=True, normalize_paths=False), help='List of exceptions for which flake8-pytest-style requires a match= argument in pytest.raises(). (Default: %(default)s)')".
flake8.options.manager    MainProcess    261 DEBUG    Registered option "Option(--pytest-parametrize-names-type, default='tuple', choices=['csv', 'tuple', 'list'], help='Preferred type for multiple parameter names in @pytest.mark.parametrize. (Default: %(default)s)')".
flake8.options.manager    MainProcess    261 DEBUG    Registered option "Option(--pytest-parametrize-values-type, default='list', choices=['tuple', 'list'], help='Preferred type for values in @pytest.mark.parametrize. (Default: %(default)s)')".
flake8.options.manager    MainProcess    261 DEBUG    Registered option "Option(--pytest-parametrize-values-row-type, default='tuple', choices=['tuple', 'list'], help='Preferred type for each row in @pytest.mark.parametrize in case of multiple parameters. (Default: %(default)s)')".
flake8.options.manager    MainProcess    261 DEBUG    Registered option "Option(--pytest-mark-no-parentheses, action='store_true', default=False, help='Omit parentheses for @pytest.mark.foo decorators without parameters. (Default: %(default)s)')".
flake8.options.manager    MainProcess    261 DEBUG    Extending default select list with ['PT']
flake8.options.manager    MainProcess    261 DEBUG    Registered option "Option(--quotes, action='store', choices=['"', "'", 'double', 'single'], help='Deprecated alias for `--inline-quotes`')".
flake8.options.manager    MainProcess    261 DEBUG    Registered option "Option(--inline-quotes, action='store', default="'", choices=['"', "'", 'double', 'single'], help="Quote to expect in all files (default: ')")".
flake8.options.manager    MainProcess    261 DEBUG    Registered option "Option(--multiline-quotes, action='store', default=None, choices=['"', '"""', "'", "'''", 'double', 'single'], help='Quote to expect in all files (default: """)')".
flake8.options.manager    MainProcess    261 DEBUG    Registered option "Option(--docstring-quotes, action='store', default=None, choices=['"', '"""', "'", "'''", 'double', 'single'], help='Quote to expect in all files (default: """)')".
flake8.options.manager    MainProcess    261 DEBUG    Registered option "Option(--avoid-escape, action='store_true', default=None, help='Avoiding escaping same quotes in inline strings (enabled by default)')".
flake8.options.manager    MainProcess    261 DEBUG    Registered option "Option(--no-avoid-escape, action='store_false', default=None, dest='avoid_escape', help='Disable avoiding escaping same quotes in inline strings')".
flake8.options.manager    MainProcess    261 DEBUG    Extending default select list with ['Q0']
flake8.options.manager    MainProcess    262 DEBUG    Registered option "Option(--banned-modules, action='store', default='', help='A map of modules to ban to the error messages to display in the error.')".
flake8.options.manager    MainProcess    262 DEBUG    Registered option "Option(--ban-relative-imports, action='store', default='', nargs='?', const='true', choices=['', 'parents', 'true'], help='Ban relative imports, from parental modules or in all cases.')".
flake8.options.manager    MainProcess    262 DEBUG    Extending default select list with ['I25']
flake8.options.manager    MainProcess    262 DEBUG    Registered option "Option(--min-python-version, default='3.5.0', type=<class 'str'>, help='Minimum version of python your code supports, (default: %(default)s)', metavar='VERSION')".
flake8.options.manager    MainProcess    262 DEBUG    Extending default select list with ['TYP']
flake8.options.manager    MainProcess    262 DEBUG    Registered option "Option(--max-complexity, action='store', default=-1, type=<class 'int'>, help='McCabe complexity threshold')".
flake8.options.manager    MainProcess    262 DEBUG    Extending default select list with ['C90']
flake8.options.manager    MainProcess    262 DEBUG    Registered option "Option(--builtins, type=functools.partial(<function _flake8_normalize at 0x100f82940>, comma_separated_list=True, normalize_paths=False), help='define more built-ins, comma separated')".
flake8.options.manager    MainProcess    262 DEBUG    Registered option "Option(--doctests, action='store_true', default=False, help='also check syntax of the doctests')".
flake8.options.manager    MainProcess    262 DEBUG    Registered option "Option(--include-in-doctest, default='', type=functools.partial(<function _flake8_normalize at 0x100f82940>, comma_separated_list=True, normalize_paths=True), dest='include_in_doctest', help='Run doctests only on these files')".
flake8.options.manager    MainProcess    262 DEBUG    Registered option "Option(--exclude-from-doctest, default='', type=functools.partial(<function _flake8_normalize at 0x100f82940>, comma_separated_list=True, normalize_paths=True), dest='exclude_from_doctest', help='Skip these files when running doctests')".
flake8.options.manager    MainProcess    262 DEBUG    Extending default select list with ['F']
flake8.options.manager    MainProcess    262 DEBUG    Extending default select list with ['E']
flake8.options.manager    MainProcess    262 DEBUG    Extending default select list with ['W']
flake8.options.manager    MainProcess    262 DEBUG    Registered option "Option(--toml-config, action='store', default=None, help='Path to custom TOML configuration file. May be located in a different folder. Overrides the default "pyproject.toml" in the current working directory.', metavar='TOML_COMFIG')".
flake8.options.config     MainProcess    262 DEBUG    Option "ignore" returned value: ['E501', 'E265', 'F811', 'BLK100', 'T003', 'E722', 'E722', 'W503', 'E203']
flake8.options.config     MainProcess    262 DEBUG    Option "max-line-length" returned value: 119
flake8.options.config     MainProcess    262 DEBUG    Option "inline-quotes" returned value: 'double'
flake8.options.config     MainProcess    262 DEBUG    Option "exclude" returned value: ['static', 'migrations', '*/migrations/*', '.git', '__pycache__', 'venv', '.venv', 'env']
flake8.options.aggregator MainProcess    262 DEBUG    Overriding default value of (None) for "ignore" with (['E501', 'E265', 'F811', 'BLK100', 'T003', 'E722', 'E722', 'W503', 'E203'])
flake8.options.aggregator MainProcess    262 DEBUG    Overriding default value of (79) for "max_line_length" with (119)
flake8.options.aggregator MainProcess    262 DEBUG    Overriding default value of (') for "inline_quotes" with (double)
flake8.options.aggregator MainProcess    263 DEBUG    Overriding default value of (['.svn', 'CVS', '.bzr', '.hg', '.git', '__pycache__', '.tox', '.nox', '.eggs', '*.egg']) for "exclude" with (['static', 'migrations', '/Users/matrix/work/pre-comm/*/migrations/*', '.git', '__pycache__', 'venv', '.venv', 'env'])
flake8                    MainProcess    263 INFO     flake8-black: No black configuration set
flake8.checker            MainProcess    263 INFO     Making checkers
flake8.discover_files     MainProcess    263 DEBUG    "/Users/matrix/work/pre-comm/admin.py" has not been excluded
flake8                    MainProcess    264 INFO     flake8-black: loading black settings from /Users/matrix/work/pre-comm/pyproject.toml
flake8                    MainProcess    264 DEBUG    flake8-black: admin.py using newly loaded /Users/matrix/work/pre-comm/pyproject.toml
flake8.processor          MainProcess    276 WARNING  Plugin requested optional parameter "builtins" but this is not an available parameter.
flake8.checker            MainProcess    277 DEBUG    Logical line: "import locale"
flake8.checker            MainProcess    278 DEBUG    Logical line: "import calendar"
flake8.checker            MainProcess    278 DEBUG    Logical line: "from django import forms"
flake8.checker            MainProcess    278 DEBUG    Logical line: "from django.contrib import admin"
flake8.checker            MainProcess    278 DEBUG    Logical line: "def check_bb(default=[]):"
flake8.checker            MainProcess    278 DEBUG    Logical line: "default.append(1)"
flake8.checker            MainProcess    278 DEBUG    Logical line: "return default"
flake8.checker            MainProcess    278 DEBUG    Logical line: "class SomeForm(forms.ModelForm):"
flake8.checker            MainProcess    278 DEBUG    Logical line: "class Meta:"
flake8.checker            MainProcess    278 DEBUG    Logical line: "model = SomeHistory"
flake8.checker            MainProcess    278 DEBUG    Logical line: "fields = "xxxxxxx""
flake8.main.application   MainProcess    278 INFO     Finished running
flake8.main.application   MainProcess    278 INFO     Reporting errors
flake8.style_guide        MainProcess    278 DEBUG    The user configured 'F401' to be <Selected.Implicitly: 'implicitly selected'>, <Selected.Implicitly: 'implicitly selected'>
flake8.style_guide        MainProcess    278 DEBUG    "F401" will be "Decision.Selected"
flake8.violation          MainProcess    278 DEBUG    Violation(code='F401', filename='admin.py', line_number=1, column_number=1, text="'locale' imported but unused", physical_line='import locale\n') is not inline ignored
flake8.style_guide        MainProcess    278 DEBUG    The user configured 'I001' to be <Selected.Implicitly: 'implicitly selected'>, <Selected.Implicitly: 'implicitly selected'>
flake8.style_guide        MainProcess    278 DEBUG    "I001" will be "Decision.Selected"
flake8.violation          MainProcess    279 DEBUG    Violation(code='I001', filename='admin.py', line_number=2, column_number=1, text='isort found an import in the wrong position', physical_line='import calendar\n') is not inline ignored
flake8.violation          MainProcess    279 DEBUG    Violation(code='F401', filename='admin.py', line_number=2, column_number=1, text="'calendar' imported but unused", physical_line='import calendar\n') is not inline ignored
flake8.violation          MainProcess    279 DEBUG    Violation(code='F401', filename='admin.py', line_number=5, column_number=1, text="'django.contrib.admin' imported but unused", physical_line='from django.contrib import admin\n') is not inline ignored
flake8.style_guide        MainProcess    279 DEBUG    The user configured 'I004' to be <Selected.Implicitly: 'implicitly selected'>, <Selected.Implicitly: 'implicitly selected'>
flake8.style_guide        MainProcess    279 DEBUG    "I004" will be "Decision.Selected"
flake8.violation          MainProcess    279 DEBUG    Violation(code='I004', filename='admin.py', line_number=6, column_number=1, text='isort found an unexpected blank line in imports', physical_line='\n') is not inline ignored
flake8.violation          MainProcess    279 DEBUG    Violation(code='I004', filename='admin.py', line_number=7, column_number=1, text='isort found an unexpected blank line in imports', physical_line='\n') is not inline ignored
flake8.style_guide        MainProcess    279 DEBUG    The user configured 'BLK100' to be <Selected.Implicitly: 'implicitly selected'>, <Ignored.Explicitly: 'explicitly ignored'>
flake8.style_guide        MainProcess    279 DEBUG    "BLK100" will be "Decision.Ignored"
flake8.violation          MainProcess    279 DEBUG    Violation(code='BLK100', filename='admin.py', line_number=8, column_number=1, text='Black would make changes.', physical_line='\n') is not inline ignored
flake8.style_guide        MainProcess    279 DEBUG    The user configured 'E303' to be <Selected.Implicitly: 'implicitly selected'>, <Selected.Implicitly: 'implicitly selected'>
flake8.style_guide        MainProcess    279 DEBUG    "E303" will be "Decision.Selected"
flake8.violation          MainProcess    279 DEBUG    Violation(code='E303', filename='admin.py', line_number=10, column_number=1, text='too many blank lines (4)', physical_line='def check_bb(default=[]):\n') is not inline ignored
flake8.style_guide        MainProcess    279 DEBUG    The user configured 'B006' to be <Selected.Implicitly: 'implicitly selected'>, <Selected.Implicitly: 'implicitly selected'>
flake8.style_guide        MainProcess    279 DEBUG    "B006" will be "Decision.Selected"
flake8.violation          MainProcess    279 DEBUG    Violation(code='B006', filename='admin.py', line_number=10, column_number=22, text='Do not use mutable data structures for argument defaults.  They are created during function definition time. All calls to the function reuse this one instance of that data structure, persisting changes between them.', physical_line='def check_bb(default=[]):\n') is not inline ignored
flake8.style_guide        MainProcess    279 DEBUG    The user configured 'F821' to be <Selected.Implicitly: 'implicitly selected'>, <Selected.Implicitly: 'implicitly selected'>
flake8.style_guide        MainProcess    279 DEBUG    "F821" will be "Decision.Selected"
flake8.violation          MainProcess    279 DEBUG    Violation(code='F821', filename='admin.py', line_number=17, column_number=17, text="undefined name 'SomeHistory'", physical_line='        model = SomeHistory\n') is not inline ignored
flake8.style_guide        MainProcess    279 DEBUG    The user configured 'W391' to be <Selected.Implicitly: 'implicitly selected'>, <Selected.Implicitly: 'implicitly selected'>
flake8.style_guide        MainProcess    279 DEBUG    "W391" will be "Decision.Selected"
flake8.violation          MainProcess    279 DEBUG    Violation(code='W391', filename='admin.py', line_number=20, column_number=1, text='blank line at end of file', physical_line='\n') is not inline ignored
flake8.main.application   MainProcess    279 INFO     Found a total of 11 violations and reported 10
admin.py:1:1: F401 'locale' imported but unused
admin.py:2:1: I001 isort found an import in the wrong position
admin.py:2:1: F401 'calendar' imported but unused
admin.py:5:1: F401 'django.contrib.admin' imported but unused
admin.py:6:1: I004 isort found an unexpected blank line in imports
admin.py:7:1: I004 isort found an unexpected blank line in imports
admin.py:10:1: E303 too many blank lines (4)
admin.py:10:22: B006 Do not use mutable data structures for argument defaults.  They are created during function definition time. All calls to the function reuse this one instance of that data structure, persisting changes between them.
admin.py:17:17: F821 undefined name 'SomeHistory'
admin.py:20:1: W391 blank line at end of file

so in that case no violations were raised.. ( Don't have and idea why, I see from logs that plugin was loaded and in both cases I see in logs line -
flake8.checker MainProcess 278 DEBUG Logical line: "fields = "xxxxxxx"" , but in case when it was run under pre-commit the DJ* was not found.

my git diff --stashed

diff --git a/admin.py b/admin.py
new file mode 100644
index 0000000..f52b780
--- /dev/null
+++ b/admin.py
@@ -0,0 +1,20 @@
+import locale
+import calendar
+
+from django import forms
+from django.contrib import admin
+
+
+
+
+def check_bb(default=[]):
+    default.append(1)
+    return default
+
+
+class SomeForm(forms.ModelForm):
+    class Meta:
+        model = SomeHistory
+        fields = "__all__"
+
+

so I'm sure it should raise DJ07 error.

@jmichalicek
Copy link

I can confirm the same issue when tested with DJ12. I put some quick print() calls in checkers/model_content_order.py and confirmed that the checker is executing and seeing the nodes and yielding a DJ12.

def get_issues(self, node):
    elements_type_found = []
    for element in node.body:
        print("checking element", repr(element))
        element_type = self.get_element_type(element)
        if not element_type:
            continue

        element_type_in_wrong_order = self.find_element_type_in_wrong_order(element_type, elements_type_found)
        if element_type_in_wrong_order:
            print("I should yield dj12")
            yield DJ12(
                element,
                element_type,
                element_type_in_wrong_order,
            )
        else:
            elements_type_found.append(element_type)

I get all of the expected output, including an "I should yield dj12", but flake8 passes.

When I just run flake8 normally, including using the one installed in the pre-commit managed venv, I do get the DJ12 error.

@jmichalicek
Copy link

@BigDeepBlue Found it. Looks like django needs included in the additional_dependencies of .pre-commit-config.yaml

@yalef
Copy link
Contributor

yalef commented Oct 27, 2023

It happens because pre-commit runs flake8 in separate environment from your development environment(where django not installed). So it can't detect if class is model or not, because it can't check is it inherited from django.db.models.Model. So you need to add django and django_extensions(if you're using it for TimeStampedModel for example) to your pre-commit config

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants