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

--filename doesn't apply to explicitly passed in paths #278

Closed
asottile opened this issue Apr 3, 2021 · 3 comments
Closed

--filename doesn't apply to explicitly passed in paths #278

asottile opened this issue Apr 3, 2021 · 3 comments

Comments

@asottile
Copy link
Member

asottile commented Apr 3, 2021

In GitLab by @anntzer on Nov 8, 2018, 02:27

Please read this brief portion of documentation before going any further: http://flake8.pycqa.org/en/latest/internal/contributing.html#filing-a-bug

Please describe how you installed Flake8

Example:

$ pip install --user flake8

in a venv.

Note: Some *nix distributions patch Flake8 arbitrarily to accommodate incompatible software versions. If you're on one of those distributions, your issue may be closed and you will be asked to open an issue with your distribution package maintainers instead.

Please provide the exact, unmodified output of flake8 --bug-report

{
  "dependencies": [
    {
      "dependency": "setuptools",
      "version": "40.5.0"
    }
  ],
  "platform": {
    "python_implementation": "CPython",
    "python_version": "3.7.0",
    "system": "Linux"
  },
  "plugins": [
    {
      "is_local": false,
      "plugin": "mccabe",
      "version": "0.6.1"
    },
    {
      "is_local": false,
      "plugin": "pycodestyle",
      "version": "2.4.0"
    },
    {
      "is_local": false,
      "plugin": "pyflakes",
      "version": "2.0.0"
    }
  ],
  "version": "3.6.0"
}

Please describe the problem or feature

The --filename=patterns filter does not apply to explicitly passed in paths.

Example:

$ echo 'abc def' > bad.txt
$ flake8 --filename='*.py' bad.txt  # Note that `'*.py'` is the default value.
bad.txt:1:7: E999 SyntaxError: invalid syntax

The use case is to actually do flake8 $(git ls-files) in a repo that 1) contains autogenerated, non-git-tracked, non-style-checked Python files (in my case, generated by sphinx-gallery), and 2) contains a lot of non-Python files, which should be skipped. (Sure, I guess I could write flake8 $(git ls-files | grep '.*\.py$') but then what's the point of having --filename? :-))

Mildly related to #392, I guess, in terms of how filter flags interact with explicit file lists.

@asottile
Copy link
Member Author

asottile commented Apr 3, 2021

In GitLab by @asottile on Nov 8, 2018, 06:45

I believe this is the intended behavior. Paths passed explicitly on the command line do not participate in inclusion / exclusion. A few other issues mentioning this behavior : #10 #218 (there's also links to others there)

You might also find git ls-files -- '*.py' slightly less clunky (or to use --exclude and flake8 . )

@asottile
Copy link
Member Author

asottile commented Apr 3, 2021

In GitLab by @sigmavirus24 on Nov 17, 2018, 05:43

@asottile You're correct.

@asottile
Copy link
Member Author

asottile commented Apr 3, 2021

In GitLab by @sigmavirus24 on Nov 17, 2018, 05:43

closed

@asottile asottile closed this as completed Apr 3, 2021
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

1 participant