GithubHelp home page GithubHelp logo

Comments (8)

jayvdb avatar jayvdb commented on May 20, 2024

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:

  1. strip leading ./ , or .\\ on windows
  2. patterns ending with / are used as exact prefix matches, so a/b/ matches anything in the a/b directory and sub-directories. this doesnt use os.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.

The-Compiler avatar The-Compiler commented on May 20, 2024

So tests/*/*/test_*.py should have worked with my example above, no? I agree your proposal would make sense.

from flake8-putty.

jayvdb avatar jayvdb commented on May 20, 2024

Yes, tests/*/*/test_*.py should have worked . I've added tests to confirm that works: 54cd2c5

from flake8-putty.

The-Compiler avatar The-Compiler commented on May 20, 2024

Hm, odd. I'll try this again later this week and come back to you.

from flake8-putty.

The-Compiler avatar The-Compiler commented on May 20, 2024

Indeed that seems to work fine - I guess I just had too many errors to notice some where gone.

from flake8-putty.

CleanCut avatar CleanCut commented on May 20, 2024

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.

jayvdb avatar jayvdb commented on May 20, 2024

I think it is too early to give * to be a filename rule. There may be better uses for it.

from flake8-putty.

jayvdb avatar jayvdb commented on May 20, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.