Comments (8)
You need to use file pattern */test_*.py
The file selecter uses fnmatch.fnmatch
with only a few improvements.
>>> import fnmatch
>>> fnmatch.fnmatch('foo/test_bar.py', '*.py')
True
>>> fnmatch.fnmatch('foo/test_bar.py', 'test_*.py')
False
>>> fnmatch.fnmatch('foo/test_bar.py', 'foo/test_*.py')
True
>>> fnmatch.fnmatch('foo/test_bar.py', '*/test_*.py')
True
>>> fnmatch.fnmatch('foo/baz/test_bar.py', '*/test_*.py')
True
Currently the improvements are:
- strip leading
./
, or.\\
on windows - patterns ending with
/
are used as exact prefix matches, soa/b/
matches anything in thea/b
directory and sub-directories. this doesnt useos.sep
, so it only works on Unix.
We could add another one to catch your scenario:
If the pattern doesn't contain a /
, do fnmatch
on the filename only.
However that would mean it isnt possible to use pattern test_*.py
to only match test_foo.py
and test_bar.py
and not match foo/test_bar.py
. With a little more complexity, this scenario could be supported by allowing the pattern ./test_*.py
to bypass the suffix match.
from flake8-putty.
So tests/*/*/test_*.py
should have worked with my example above, no? I agree your proposal would make sense.
from flake8-putty.
Yes, tests/*/*/test_*.py
should have worked . I've added tests to confirm that works: 54cd2c5
from flake8-putty.
Hm, odd. I'll try this again later this week and come back to you.
from flake8-putty.
Indeed that seems to work fine - I guess I just had too many errors to notice some where gone.
from flake8-putty.
So, why does *
not work, but *.py
will? I was trying to add a global ignore list to your flake8-putty contribution to green, but the flake8 ignore setting was ignored, and something like this is ignored as well:
* : +C901
But after reading this thread, I tried this, which works:
*.py : +C901
from flake8-putty.
I think it is too early to give *
to be a filename rule. There may be better uses for it.
from flake8-putty.
I tested tests/*/test_*.py : +D100,D101,D401
in the qutebrowser repo, and it [[https://travis-ci.org/jayvdb/qutebrowser/builds/121606076|worked]] as expected, so closing this ticket.
Further regarding * : xxx
, to ignore C901 unconditionally it can be added to flake8
's ignore
list. i.e. flake8-putty
isnt needed for unconditional ignores. But as you've demonstrated, an almost unconditional ignore *.py : x
does work.
I've raised #8 and #9 to track tangential ideas raised in this ticket.
from flake8-putty.
Related Issues (17)
- require code
- line continuation operator HOT 1
- Logical line support
- comments at end of line are not stripped HOT 2
- Ability to change flake8 flags on the fly in source file via inline comments
- putty is not flake8 v3 compatible HOT 16
- flake8 3.0 includes per line noqa HOT 12
- comment in tox dependencies causes packaging.InvalidRequirement HOT 6
- Newbie question on how to actual get putty to be applied HOT 11
- Predefined ignore patterns HOT 8
- Multiline regex pattern HOT 4
- Selector for python version HOT 2
- Implement recognition of pylint code disabling comments
- Ignore rules in comment at top of module HOT 1
- Microsoft Windows support HOT 3
- Finalise matching algorithm for filenames without a directory separator
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flake8-putty.