The strictest and most opinionated python linter ever!

Overview

wemake-python-styleguide

wemake.services Supporters Build Status codecov Python Version wemake-python-styleguide


Welcome to the strictest and most opinionated python linter ever.

wemake-python-styleguide logo

wemake-python-styleguide is actually a flake8 plugin with some other plugins as dependencies.

Quickstart

pip install wemake-python-styleguide

You will also need to create a setup.cfg file with the configuration.

We highly recommend to also use:

  • flakehell for easy integration into a legacy codebase
  • nitpick for sharing and validating configuration across multiple projects

Running

flake8 your_module.py

This app is still just good old flake8! And it won't change your existing workflow.

invocation results

See "Usage" section in the docs for examples and integrations.

We also support GitHub Actions as first class-citizens. Try it out!

What we are about

The ultimate goal of this project is to make all people write exactly the same python code.

flake8 pylint black mypy wemake-python-styleguide
Formats code?
Finds style issues? 🤔 🤔
Finds bugs? 🤔
Finds complex code? 🤔
Has a lot of strict rules? 🤔
Has a lot of plugins? 🤔

We have several primary objectives:

  1. Enforce python3.6+ usage
  2. Significantly reduce complexity of your code and make it more maintainable
  3. Enforce "There should be one -- and preferably only one -- obvious way to do it" rule to coding and naming styles
  4. Protect developers from possible errors and enforce best practices

You can find all error codes and plugins in the docs.

What we are not

We are not planning to do the following things:

  1. Assume or check types, use mypy together with our linter
  2. Reformat code, since we believe that developers should do that
  3. Check for SyntaxError or logical bugs, write tests instead
  4. Appeal to everyone. But, you can switch off any rules that you don't like

Supporting us 🎉

We in wemake.services make all our tools open-source by default, so the community can benefit from them. If you use our tools and they make your life easier and brings business value, you can return us a favor by supporting the work we do.

Gold Tier

Silver Tier

Bronze Tier

Show your style 😎

If you use our linter - it means that your code is awesome. You can be proud of it! And you should share your accomplishment with others by including a badge to your README file. It looks like this:

wemake-python-styleguide

Markdown

[![wemake-python-styleguide](https://img.shields.io/badge/style-wemake-000000.svg)](https://github.com/wemake-services/wemake-python-styleguide)

Restructured text

.. image:: https://img.shields.io/badge/style-wemake-000000.svg
   :target: https://github.com/wemake-services/wemake-python-styleguide

Contributing

We warmly welcome all contributions!

List of contributors

See "Contributing" section in the documentation if you want to contribute.

You can start with issues that need some help right now.

Comments
  • Warn about possibly infinite `while`

    Warn about possibly infinite `while`

    Rule request

    Check that while True block has raise or return.

    UPD: and break too.

    Thesis

    It's OK to not have them for CLI entry point, but in other cases, it can be an error. So, let's ask users explicitly noqa such cases to be sure that they really know what they're doing.

    Reasoning

    help wanted level:starter rule request pr-available 
    opened by orsinium 23
  • Unnecessary literals

    Unnecessary literals

    Rule request

    Thesis

    Bad:

    int()
    float()
    str()
    bytes()
    bool()
    complex()
    

    Good:

    0
    0.0
    ''
    b''
    False
    0j
    

    flake8-comprehensions does the same, but only for dict, list, and tuple.

    Reasoning

    There should be one-- and preferably only one --obvious way to do it.

    help wanted level:starter rule request Hacktoberfest pr-merged 
    opened by orsinium 22
  • Fix for issue 649.

    Fix for issue 649.

    I have made things!

    Checklist

    • [ ] I have double checked that there are no unrelated changes in this pull request (old patches, accidental config files, etc)
    • [ ] I have created at least one test case for the changes I have made
    • [ ] I have updated the documentation for the changes I have made
    • [ ] I have added my changes to the CHANGELOG.md

    Related issues

    opened by NanduTej 22
  • Early return should not take `return None` form when it is not required

    Early return should not take `return None` form when it is not required

    Rule request

    Thesis

    Right now this code:

        def _check_parent(self, node: ast.If) -> None:
            parent = get_parent(node)
    
            if parent is None:
                return None
    
            if isinstance(parent, _ELSE_NODES):
                body = parent.body + parent.orelse
            else:
                body = getattr(parent, 'body', [node])
    
            next_index_in_parent = body.index(node) + 1
            if keywords.next_node_returns_bool(body, next_index_in_parent):
                self.add_violation(SimplifiableReturningIfViolation(node))
    

    passes our style check. Note return None part there. It is the only return. And it means that None part is not required. Moreover, it should not be allowed. Simple early returns must be justreturn`.

    help wanted level:starter rule request good first issue 
    opened by sobolevn 21
  • Bump flake8-isort min version to 3.0.1

    Bump flake8-isort min version to 3.0.1

    After the release of isort==5.0.0, flake8-isort stopped working: https://github.com/gforcada/flake8-isort/issues/88.

    The flake8-isort==3.0.1 patches this by limiting the isort version to lower than 5 in its dependencies: https://github.com/gforcada/flake8-isort/pull/89. I think, this dist should set flake8-isort >=3.0.1, <4 in the install requirements.

    bug help wanted dependencies pr-merged good first issue 
    opened by webknjaz 21
  • Forbid compares with `0` and `''`

    Forbid compares with `0` and `''`

    Rule request

    Thesis

    We can omit compare with 0 and '', because not something is enough. We should forbid is, not is, ==, !=

    Reasoning

    This is a best practice from python world.

    help wanted level:starter rule request 
    opened by sobolevn 21
  • "pyflakes" failed during execution due to "'ExceptHandler' object has no attribute 'depth'"

    Bug report

    What's wrong

    flake8 fails to run pyflakes when flake-bandit version is >=2.0.0 changing flake-bandit version to 1.0.2 fixes the error. Similar error was reported earlier https://github.com/wemake-services/wemake-python-styleguide/issues/112

    main.py

    def test():
        try:
            x = 5
            if True:
                x = 10
        except AttributeError:
            pass
    
    

    There should be if inside try block with at least one except clause. The variable shoud be defined inside try and reassigned inside if. Also using bare except removes the error.

    flake8 main.py
    "pyflakes" failed during execution due to "'ExceptHandler' object has no attribute 'depth'"
    Run flake8 with greater verbosity to see more details
    

    pyflakes breaks here when for some reason rnode has attrbute parent but doesn't have depth.

    How is that should be

    It should not raise any errors.

    System information

    flake8 information

    {
      "dependencies": [
        {
          "dependency": "entrypoints",
          "version": "0.3"
        }
      ],
      "platform": {
        "python_implementation": "CPython",
        "python_version": "3.6.7",
        "system": "Linux"
      },
      "plugins": [
        {
          "is_local": false,
          "plugin": "flake8-annotations-complexity",
          "version": "0.0.2"
        },
        {
          "is_local": false,
          "plugin": "flake8-bandit",
          "version": "2.1.0"
        },
        {
          "is_local": false,
          "plugin": "flake8-broken-line",
          "version": "0.1.0"
        },
        {
          "is_local": false,
          "plugin": "flake8-bugbear",
          "version": "18.8.0"
        },
        {
          "is_local": false,
          "plugin": "flake8-comprehensions",
          "version": "2.1.0"
        },
        {
          "is_local": false,
          "plugin": "flake8-debugger",
          "version": "3.1.0"
        },
        {
          "is_local": false,
          "plugin": "flake8-docstrings",
          "version": "1.3.0, pydocstyle: 3.0.0"
        },
        {
          "is_local": false,
          "plugin": "flake8-eradicate",
          "version": "0.2.0"
        },
        {
          "is_local": false,
          "plugin": "flake8-print",
          "version": "3.1.0"
        },
        {
          "is_local": false,
          "plugin": "flake8-string-format",
          "version": "0.2.3"
        },
        {
          "is_local": false,
          "plugin": "flake8_builtins",
          "version": "1.4.1"
        },
        {
          "is_local": false,
          "plugin": "flake8_coding",
          "version": "1.3.1"
        },
        {
          "is_local": false,
          "plugin": "flake8_commas",
          "version": "2.0.0"
        },
        {
          "is_local": false,
          "plugin": "flake8_isort",
          "version": "2.3"
        },
        {
          "is_local": false,
          "plugin": "flake8_pep3101",
          "version": "1.2.1"
        },
        {
          "is_local": false,
          "plugin": "flake8_quotes",
          "version": "1.0.0"
        },
        {
          "is_local": false,
          "plugin": "logging-format",
          "version": "0.6.0"
        },
        {
          "is_local": false,
          "plugin": "mccabe",
          "version": "0.6.1"
        },
        {
          "is_local": false,
          "plugin": "naming",
          "version": "0.8.2"
        },
        {
          "is_local": false,
          "plugin": "pycodestyle",
          "version": "2.5.0"
        },
        {
          "is_local": false,
          "plugin": "pyflakes",
          "version": "2.1.1"
        },
        {
          "is_local": false,
          "plugin": "wemake-python-styleguide",
          "version": "0.8.0"
        }
      ],
      "version": "3.7.7"
    }
    
    

    For some reason I cannot reproduce this in fresh environment, trying to investigate.

    pip freeze

    astor==0.7.1
    attrs==18.2.0
    bandit==1.5.1
    entrypoints==0.3
    eradicate==1.0
    flake8==3.7.7
    flake8-annotations-complexity==0.0.2
    flake8-bandit==2.1.0
    flake8-broken-line==0.1.0
    flake8-bugbear==18.8.0
    flake8-builtins==1.4.1
    flake8-coding==1.3.1
    flake8-commas==2.0.0
    flake8-comprehensions==2.1.0
    flake8-debugger==3.1.0
    flake8-docstrings==1.3.0
    flake8-eradicate==0.2.0
    flake8-isort==2.6.0
    flake8-logging-format==0.6.0
    flake8-pep3101==1.2.1
    flake8-polyfill==1.0.2
    flake8-print==3.1.0
    flake8-quotes==1.0.0
    flake8-string-format==0.2.3
    gitdb2==2.0.5
    GitPython==2.1.11
    isort==4.3.15
    mccabe==0.6.1
    pbr==5.1.3
    pep8-naming==0.8.2
    pycodestyle==2.5.0
    pydocstyle==3.0.0
    pyflakes==2.1.1
    PyYAML==5.1
    six==1.12.0
    smmap2==2.0.5
    snowballstemmer==1.2.1
    stevedore==1.30.1
    testfixtures==6.6.1
    typing==3.6.6
    typing-extensions==3.7.2
    wemake-python-styleguide==0.8.0
    
    bug dependencies level:advanced 
    opened by alextatarinov 21
  • `get_*` functions must return something.

    `get_*` functions must return something.

    Rule request

    Thesis

    Functions and methods with get_ prefix must return something (have return or yield in the body).

    Reasoning

    get_ function is expected to return what it promises to return. For example, get_user returns a user object. If it's not so, it's an error or a bad interface.

    help wanted level:starter rule request Hacktoberfest 
    opened by orsinium 19
  • Forbid `Union[T, None]`, use `Optional[T]` instead

    Forbid `Union[T, None]`, use `Optional[T]` instead

    Rule request

    Thesis

    One can write Optional[T] to indicate that T and None can be returned. This is a valid way to do it.

    But Union[T, None] is invalid. And should be forbidden.

    I have to note that Union[A, B, C, None] is ok.

    Reasoning

    This is a consistency rule.

    help wanted level:starter rule request Hacktoberfest pr-rejected 
    opened by sobolevn 19
  • Added TooLongVariableNameViolation

    Added TooLongVariableNameViolation

    I have made things!

    Checklist

    • [x] I have double checked that there are no unrelated changes in this pull request (old patches, accidental config files, etc)
    • [x] I have created at least one test case for the changes I have made
    • [x] I have updated the documentation for the changes I have made
    • [x] I have added my changes to the CHANGELOG.md

    Related issues

    Closes #288 Refs #288

    Let me know if anything needs to be changed! 😄

    opened by Casva 19
  • Forbid consecutive slices

    Forbid consecutive slices

    Rule request

    Thesis

    We should forbid consecutive slices.

    Reasoning

    Consider this code:

    >>> a = [1, 2, 3, 4]
    >>> a[1:][:2]
    [2, 3]
    

    What it does?

    1. a[1:] is [2, 3, 4]
    2. [2, 3, 4][:2] is [2, 3]

    It is much more readable and effective to use

    >>> a[1:3]
    [2, 3]
    

    Related https://twitter.com/m_ou_se/status/1403426221367627777

    help wanted level:starter rule request good first issue 
    opened by sobolevn 18
  • Bump flake8-isort from 5.0.0 to 6.0.0

    Bump flake8-isort from 5.0.0 to 6.0.0

    Bumps flake8-isort from 5.0.0 to 6.0.0.

    Changelog

    Sourced from flake8-isort's changelog.

    6.0.0 (2022-12-22)

    • Drop isort 4.x support. [gforcada]

    • Add support for flake8 6.0.0. [gforcada]

    • Add --isort-no-skip-gitignore option to allow temporarily overriding 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. [gschaffner]

    5.0.3 (2022-11-20)

    • Fix broken add_options method, again. [casperdcl]

    5.0.2 (2022-11-19)

    • Fix broken add_options method [casperdcl]

    5.0.1 (2022-11-18)

    • Improve the config option is added and read back. [gforcada]

    • Bump plugin version. [gforcada]

    Commits
    • 5d55a7e Preparing release 6.0.0
    • 54b2052 Merge pull request #135 from gforcada/gforcada-patch-1
    • 1525065 Update CHANGES
    • 2ef02bf chore(ci): test with flake8 6.0.0
    • 85c1018 Merge pull request #130 from gschaffner/no-skip-gitignore
    • 65c1a59 Merge pull request #133 from gforcada/drop-isort-4
    • eb16f5d Update CHANGES
    • 9e37bf4 chore(ci): bump isort version tested
    • 4d0cdb4 chore: bump isort restriction
    • 41604b1 breaking: remove isort 4 code
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies python 
    opened by dependabot[bot] 1
  • Bump attrs from 22.1.0 to 22.2.0

    Bump attrs from 22.1.0 to 22.2.0

    Bumps attrs from 22.1.0 to 22.2.0.

    Release notes

    Sourced from attrs's releases.

    22.2.0

    Highlights

    It's been a lot busier than the changelog indicates, but a lot of the work happened under the hood (like some impressive performance improvements). But we've got still one big new feature that's are worthy the holidays:

    Fields now have an alias argument that allows you to set the field's name in the generated __init__ method. This is especially useful for those who aren't fans of attrs's behavior of stripping underscores from private attribute names.

    Special Thanks

    This release would not be possible without my generous sponsors! Thank you to all of you making sustainable maintenance possible! If you would like to join them, go to https://github.com/sponsors/hynek and check out the sweet perks!

    Above and Beyond

    Variomedia AG (@​variomedia), Tidelift (@​tidelift), Sentry (@​getsentry), HiredScore (@​HiredScore), FilePreviews (@​filepreviews), and Daniel Fortunov (@​asqui).

    Maintenance Sustainers

    @​rzijp, Adam Hill (@​adamghill), Dan Groshev (@​si14), Tamir Bahar (@​tmr232), Adi Roiban (@​adiroiban), Magnus Watn (@​magnuswatn), David Cramer (@​dcramer), Moving Content AG (@​moving-content), Stein Magnus Jodal (@​jodal), Iwan Aucamp (@​aucampia), ProteinQure (@​ProteinQure), Jesse Snyder (@​jessesnyder), Rivo Laks (@​rivol), Thomas Ballinger (@​thomasballinger), @​medecau, Ionel Cristian Mărieș (@​ionelmc), The Westervelt Company (@​westerveltco), Philippe Galvan (@​PhilippeGalvan), Birk Jernström (@​birkjernstrom), Jannis Leidel (@​jezdez), Tim Schilling (@​tim-schilling), Chris Withers (@​cjw296), and Christopher Dignam (@​chdsbd).

    Not to forget 2 more amazing humans who chose to be generous but anonymous!

    Full Changelog

    Backwards-incompatible Changes

    • Python 3.5 is not supported anymore. #988

    Deprecations

    • Python 3.6 is now deprecated and support will be removed in the next release. #1017

    Changes

    • attrs.field() now supports an alias option for explicit __init__ argument names.

      Get __init__ signatures matching any taste, peculiar or plain! The PEP 681 compatible alias option can be use to override private attribute name mangling, or add other arbitrary field argument name overrides. #950

    • attrs.NOTHING is now an enum value, making it possible to use with e.g. typing.Literal. #983

    • Added missing re-import of attr.AttrsInstance to the attrs namespace. #987

    • Fix slight performance regression in classes with custom __setattr__ and speedup even more. #991

    • Class-creation performance improvements by switching performance-sensitive templating operations to f-strings.

      You can expect an improvement of about 5% -- even for very simple classes. #995

    ... (truncated)

    Changelog

    Sourced from attrs's changelog.

    22.2.0 - 2022-12-21

    Backwards-incompatible Changes

    • Python 3.5 is not supported anymore. #988

    Deprecations

    • Python 3.6 is now deprecated and support will be removed in the next release. #1017

    Changes

    • attrs.field() now supports an alias option for explicit __init__ argument names.

      Get __init__ signatures matching any taste, peculiar or plain! The PEP 681 compatible alias option can be use to override private attribute name mangling, or add other arbitrary field argument name overrides. #950

    • attrs.NOTHING is now an enum value, making it possible to use with e.g. typing.Literal. #983

    • Added missing re-import of attr.AttrsInstance to the attrs namespace. #987

    • Fix slight performance regression in classes with custom __setattr__ and speedup even more. #991

    • Class-creation performance improvements by switching performance-sensitive templating operations to f-strings.

      You can expect an improvement of about 5% -- even for very simple classes. #995

    • attrs.has() is now a TypeGuard for AttrsInstance. That means that type checkers know a class is an instance of an attrs class if you check it using attrs.has() (or attr.has()) first. #997

    • Made attrs.AttrsInstance stub available at runtime and fixed type errors related to the usage of attrs.AttrsInstance in Pyright. #999

    • On Python 3.10 and later, call abc.update_abstractmethods() on dict classes after creation. This improves the detection of abstractness. #1001

    • attrs's pickling methods now use dicts instead of tuples. That is safer and more robust across different versions of a class. #1009

    • Added attrs.validators.not_(wrapped_validator) to logically invert wrapped_validator by accepting only values where wrapped_validator rejects the value with a ValueError or TypeError (by default, exception types configurable). #1010

    • The type stubs for attrs.cmp_using() now have default values. #1027

    • To conform with PEP 681, attr.s() and attrs.define() now accept unsafe_hash in addition to hash. #1065

    Commits
    • a9960de Prepare 22.2.0
    • 566248a Don't linkcheck tree links
    • 0f62805 Make towncrier marker independent from warning
    • b9f35eb Fix minor stub issues (#1072)
    • 4ad4ea0 Use MyST-native include
    • 519423d Use MyST-native doctest blocks in all MD
    • 403adab Remove stray file
    • 6957e4a Use new typographic branding in the last rst file, too
    • 1bb2864 Convert examples.rst to md
    • c1c24cc Convert glossary.rst to md
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies python 
    opened by dependabot[bot] 0
  • Bump flake8-quotes from 3.3.1 to 3.3.2

    Bump flake8-quotes from 3.3.1 to 3.3.2

    Bumps flake8-quotes from 3.3.1 to 3.3.2.

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies python 
    opened by dependabot[bot] 0
  • Bump pep8-naming from 0.13.2 to 0.13.3

    Bump pep8-naming from 0.13.2 to 0.13.3

    Bumps pep8-naming from 0.13.2 to 0.13.3.

    Release notes

    Sourced from pep8-naming's releases.

    0.13.3

    • Formally require flake8 5.0.0 or later.
    • Add support for Python 3.11.
    Changelog

    Sourced from pep8-naming's changelog.

    0.13.3 - 2022-12-19

    • Formally require flake8 5.0.0 or later.
    • Add support for Python 3.11.
    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies python 
    opened by dependabot[bot] 0
  • issue - 1343

    issue - 1343

    I have made things!

    Checklist

    • [x] I have double checked that there are no unrelated changes in this pull request (old patches, accidental config files, etc)
    • [x] I have created at least one test case for the changes I have made
    • [x] I have updated the documentation for the changes I have made
    • [x] I have added my changes to the CHANGELOG.md

    Related issues

    🙏 Please, if you or your company is finding wemake-python-styleguide valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/wemake-python-styleguide. As a thank you, your profile/company logo will be added to our main README which receives hundreds of unique visitors per day.

    opened by yvvym 0
  • Allow custom short names

    Allow custom short names

    Rule request

    While some short names have been whitelisted in #1548, there are still cases when using short names is justified. For example, albumenatations library uses A as an alias in their examples. Or x and y are common names in machine learning. Disabling the entire WPS111 rule would be too broad, while putting noqa would pollute the code. There is an option to add allowed domain names (#1106), but this does not exclude them from the WPS111 rule.

    Thesis

    Make adding variable names to allowed domain names exclude them from the WPS111 rule.

    Reasoning

    There are still short names that are justified to be used in some domains. Like x and y in machine learning or A as an alias for the albumentations library.

    rule request 
    opened by rusmux 1
Releases(0.17.0)
  • 0.17.0(Sep 27, 2022)

    Features

    • Breaking: drops python3.6 support
    • Adds support for pattern matching naming rules, same as other variables
    • Adds --show-violation-links option to show links to violation docs
    • Adds __init_subclass__ in the beginning of accepted methods order as per WPS338 #2411
    • Adds WrongEmptyLinesCountViolation to check for too many lines in functions and methods definitions #2486

    Bugfixes

    • Fixes WPS226 false positives on | use in SomeType | AnotherType type hints syntax
    • Now -1 is not reported to be an overused expression
    • Allow __aiter__ to be async iterator
    • Adds violation method name to error message of YieldMagicMethodViolation
    • Fixes direct docker image invocation #2492

    Misc

    • Adds full violation codes to docs and BaseViolation.full_code #2409
    • Fix documentation mismatch between default setting for max-string-usages and enforced rule #2456
    • Domain name was changed from wemake-python-stylegui.de to wemake-python-styleguide.rtfd.io
    Source code(tar.gz)
    Source code(zip)
  • 0.16.1(Mar 11, 2022)

    Bugfixes

    • Fixes crash on 'Literal["raise"]' annotation #2341
    • Fixes WPS471 was not detected on complex assignment targets #2301
    • Fixes flake8-bandit and bandit version conflict #2368
    Source code(tar.gz)
    Source code(zip)
  • 0.16.0(Dec 13, 2021)

    Features

    • Supports new flake8 version 4.x
    • Now InconsistentYieldViolation and InconsistentReturnViolation are raised when yield or return is used with None where plain version should be used #2151
    • Dot '.' and comma ',' do not count against string literal overuse limit anymore #2209
    • Added RedundantEnumerateViolation #1825
    • Adds RaiseFromItselfViolation #2133
    • Adds ConsecutiveSlicesViolation #2064
    • Adds KwargsUnpackingInClassDefinitionViolation #1754
    • DirectMagicAttributeAccessViolation now only flags instances for which a known alternative exists #2268
    • Forbids getting collection element of list by unpacking #1824
    • Now WPS227 forbids returning tuples that are too long #1731

    Bugfixes

    • Fixes that InconsistentComprehensionViolation was ignoring misaligned in expressions #2075
    • Fixes some common magic methods not being recognized as such #2281

    Misc

    • Removes all Raises: from docstrings, they were unused
    • Improve Docs: Fixed all typos and grammatical errors in CHANGELOG.md
    • Updated documentation with the recommended isort config. #1934
    • Updates typing_extensions to 4.x
    Source code(tar.gz)
    Source code(zip)
  • 0.15.3(Jun 21, 2021)

    Bugfixes

    • Fixes crash on python3.10
    • Fixes UselessReturningElseViolation to not report else with break #1958
    • Fixes ReassigningVariableToItselfViolation to not report on x = (x,) #1807
    • Fixes ReassigningVariableToItselfViolation to extract variables from unary operators #1874
    • Fixes that f'{some:,}' was considered too complex #1921
    • Fixes that range(len(x)) was not allowed even outside for loops #1883

    Misc

    • Adds documentation (and tests) for how to run project on Jupyter Notebooks
    • Updates mypy to 0.902 and fixes type issues
    Source code(tar.gz)
    Source code(zip)
  • 0.15.2(Feb 27, 2021)

    Bugfixes

    • Fixes BitwiseAndBooleanMixupViolation work with PEP 604 union types #1884
    • Fixes CognitiveModuleComplexityViolation to not trigger for a single-item modules
    • Fixes that ConstantConditionViolation was not reported for a BoolOp
    • Functions and methods marked as @overload or @typing.overload do not count in complexity rules

    Misc

    • Updates GitHub Action's base Python image version to 3.8.8
    Source code(tar.gz)
    Source code(zip)
  • 0.15.1(Feb 12, 2021)

    Bugfixes

    • Fixes dataclasses import, it was failing on python3.6
    • Fixes InconsistentComprehensionViolation work with async comprehensions
    • Fixes nested compehensions support for InconsistentComprehensionViolation
    • Fixes multiple if support for InconsistentComprehensionViolation
    • Fixes that NestedTernaryViolation was not reported for a comprehension
    • Fixes that ConstantConditionViolation was not reported for a comprehension
    • Fixes that ConstantConditionViolation was triggering for while x := True:
    • Fixes that UselessElseViolation was not reported for for, while, and try keywords
    • Fixes false positive InfiniteWhileLoopViolation for try #1857
    • Fixes that InfiniteWhileLoopViolation was not triggered on 1 or other truthy nodes

    Misc

    • Refactors how tokenize tests are executed, now we have an option to compile fixture code to make sure it is syntatically valid
    Source code(tar.gz)
    Source code(zip)
  • 0.15.0(Feb 9, 2021)

    Features

    • Adds python3.9 support
    • Forbids to use new-style decorators on python3.9
    • Changes how we treat own/foreign attributes, since now we only check assigned attribute names for self/cls/mcs, but not any other ones. So, now writting point.x = 1 will not trigger any violations. Previously, it would raise "too short name".
    • Forbids using non-trivial expressions as an argument to except
    • Forbids using too many variables in a tuple unpacking
    • Forbids using float("NaN").
    • Forbids assigning to a slice
    • Allow __call__ method to be asynchronous
    • Allows common strings not to be counted against string constant overuse limit
    • Forbids to unpack iterable objects to lists #1259
    • Forbids to use single return None
    • Add __await__ to the list of priority magic methods
    • Forbids to use float zeros (0.0)
    • Forbids raise Exception and raise BaseException
    • Forbids to use % with zero as the divisor
    • WPS531: Forbids testing conditions to just return booleans when it is possible to simply return the condition itself
    • Forbids to use unsafe infinite loops
    • Forbids to use raw strings r'' when not necessary
    • Forbids to use too complex f-strings
    • Forbids to use too many raise statements inside a single function
    • Forbids to compare with float and complex values
    • Forbids single element destruct
    • Forbids to ignore some violations (configurable) on a line level
    • Forbids single element unpacking
    • Forbids to unpack lists with side-effects
    • Forbids to use miltiline strings except for assignments and docstrings
    • Forbids not returning anything in functions and methods starting with get_
    • Forbids to use empty comment
    • Forbids using bitwise operation with boolean operation
    • Forbids inconsistent structuring of multiline comprehensions
    • Forbids to use unpythonic getters and setters such as get_attribute or set_attribute
    • Now credits, license, and copyright builtins are free to shadow

    Bugfixes

    • Fixes fails of annotation complexity on Literal[""]
    • Fixes how wrong variable names were checked case sensitive with WPS110
    • Fixes false positives DirectMagicAttributeAccessViolation with __mro__, __subclasses__ and __version__
    • Make WPS326 work when there is comment between string literals
    • Allowed yield statements in call method
    • Allow to use ^ with 1
    • Fixes false positives in WPS513 and WPS323
    • Fixes false positive WPS426 if lambda in loop uses only its arguments
    • Fixes false negative WPS421 with pprint.pprint
    • Fixes WPS441 triggering when reusing variable names in multiple loops
    • Fixes false positive ImplicitEnumerateViolation on range with step #1742
    • Allows to use _ to declare several unused variables, like: x, _, _ = coordinates()
    • Fixes variable reassignment in class context
    • Fixes that *'abc' was not counted as pointless star expression
    • Fixes that -some was counted as overused expression
    • Fixes several bugs with attribute names

    Misc

    • Updates lots of dependenices
    • Fixed documentation for TooManyPublicAttributesViolation
    • Updated isort config
    • Introduce helper script to check for missing calls to self.generic_visit(node) in AST visitors
    • Updates poetry version to 1.1
    • Updates reviewdog version to 0.11.0 and adds action-depup
    Source code(tar.gz)
    Source code(zip)
  • 0.14.1(Jul 29, 2020)

  • 0.14.0(Mar 22, 2020)

    This release was focused on adding python3.8 support, removing dependencies that can be removed, and fixing bugs.

    There are breaking changes ahead!

    We also have this nice migration guide.

    One more thing: flake8 still fails on := operator. And there's nothing we can do about it. Please, be patient – this linter does not allow to have := in the source code anyway!

    Features

    • Breaking: removes flake8-executable, now using WPS452 instead of EXE001..EXE005
    • Breaking: removes flake8-print, now using WPS421 instead of T001
    • Breaking: removes flake8-builtins, now using WPS125 instead of A001..A005
    • Breaking: removes flake8-annotations-complexity, now using WPS234 instead of TAE002
    • Breaking: removes flake8-pep3101, now using WPS323 instead of S001, we also use a new logic for this violation: we check string defs for % patterns, and not for % operator
    • Breaking: WPS441 is no longer triggered for except blocks, it is now handled by F821 from flake8
    • Breaking: removes radon, because cognitive-complexity and mccabe is enough
    • Breaking: removes flake8-loggin-format as a direct dependency
    • Breaking: removes ImplicitTernaryViolation or WPS332, because it has too many false positives #1099
    • Removes flake8-coding, all encoding strings, visitor and tests for old WPS323 which is now reused for modulo formatting checks
    • Adds python3.8 support
    • Changes styleguide.toml and flake8.toml scripts definition
    • Extracts new violation - WPS450 from WPS436 #1118
    • Adds domain names options: --allowed-domain-names and --forbidden-domain-names, that are used to create variable names' blacklist #1106
    • Forbids to use \r (carriage return) as line breaks in strings #1111
    • Forbids to use := operator, it now reuses WPS332 code
    • Forbids to use positional only / arguments
    • Forbids to have too many names imported from a single from ... import
    • Forbids to use continue and break in finally
    • Forbids to use __reduce__ and __reduce_ex__ magic methods
    • Adds __call__ to list of methods that should be on top #1125
    • Allows _ to be now used as a defined variable
    • Removes cognitive_complexity dependency, now it is built in into our linter
    • Adds baseline information for all complexity violation messages: x > baseline
    • Changes how cognitive complexity is calculated
    • Adds support for positional arguments in different checks
    • Adds UnreadableNameViolation as WPS124 because there are some character combination which is not easy to read
    • Adds support for NamedExpr with in compare type violation

    Bugfixes

    • Fixes how i_control_code behaves with WPS113
    • Fixes that cognitive complexity was ignoring ast.Continue, ast.Break, and ast.Raise statements
    • Fixes that cognitive complexity was ignoring ast.AsyncFor loops
    • Fixes that annotation complexity was not reported for async functions
    • Fixes that annotation complexity was not reported for lists
    • Fixes that annotation complexity was not reported for * and / args
    • Fixes that annotation complexity was not tested for dot notation attributes
    • Fixes that annotation complexity fails on string expressions
    • Fixes bug when TooManyPublicAttributesViolation was counting duplicate fields
    • Fixes negated conditions WPS504 was not reported for if expressions
    • Fixes that import dumps was reported as WPS347, now only from ... import dumps is checked
    • Fixes that from some import a as std was reported as a vague import with WPS347 despite having a meaningful alias
    • Fixes that WPS501 was reported for @contextmanager definition
    • Fixes WPS226 to be thrown at nested string type annotations
    • Fixes WPS204 reported simplest nodes as overused like [] and call()
    • Fixes WPS204 not reporting overused f strings
    • Fixes WPS204 reporting overused return type annotations
    • Fixes WPS204 reporting self. attribute access
    • Fixes WPS331 reporting cases that do require some extra steps before return
    • Fixes WPS612 not reporing super() calls without return
    • Fixes WPS404 not raising on wrong * and / defaults
    • Fixes WPS425 raising on .get, getattr, setattr, and other builtin functions without keyword arguments
    • Fixes WPS221 reporting differently on different python versions
    • Fixes WPS221 reporting nested variable annotations
    • Fixes WPS509 not reporting nested ternary in grandchildren of if
    • Fixes WPS509 not reporting nested ternary in ternary
    • Fixes WPS426 not reporting nested lambda in comprehensions
    • Fixes several violations to reporting for ast.Bytes and ast.FormattedStr where ast.Str was checked
    • Fixes WPS601 reporting shadowing for non-self attributes
    • Fixes WPS114 not to be so strict
    • Fixes WPS122 not raising for for and async for definitions
    • Fixes WPS400 raising for # type: ignore[override] comments
    • Fixes WPS115 not raising for attributes inside other nodes

    Misc

    • Changes how tests are executed
    • Changes how coverage is calculated, adds coverage-conditional-plugin
    • Adds how a violation can be deprecated
    • Improves old visitor tests with / argument cases
    • Improves old visitor tests with := cases
    • Adds local-partial-types to mypy config
    • Uses abc stdlib's module to mark abstract base classes #1122
    • Adds python3.8 to the CI
    • Updates a lot of dependencies
    Source code(tar.gz)
    Source code(zip)
  • 0.13.4(Jan 19, 2020)

    This is the last 0.13.x supporting release, we have to concentrate on python3.8 support and 0.14.0 which will introduce it to the public.

    Bugfixes

    • Fix false positive ImplicitYieldFromViolation for async functions #1057
    • Fixes nested-classes-whitelist option default value for flake8 prior 3.7.8 #1093
    • Improve boolean non-keyword arguments validation #1114

    Misc

    • Updates flake8-pep3101
    • Updates flake8-builtins
    • Updates flake8-eradicate
    • Several small refactoring sessions
    • Adds hypothesis-based tests
    • Adds flakehell base config
    • Fixes flakehell docs
    • Fixes MAX_NOQA_COMMENTS and related violation docs
    • Fixes OverusedExpressionViolation and TooManyExpressionsViolation docs
    Source code(tar.gz)
    Source code(zip)
  • 0.13.3(Dec 15, 2019)

  • 0.13.2(Dec 10, 2019)

    Bugfixes

    • Fixes that Github Action was failing for wrong status code
    • Fixes NegatedConditionsViolation false positive on absent else in combination with elif
    • Fixes WPS528 false positive on augmented assigns
    • Fixes incorrect message for WPS349
    • Fixes that reviewdog was not able to create more than 30 comments per PR

    Misc

    • pylint docs fixed
    • Fixes docs about implicit yield violation
    Source code(tar.gz)
    Source code(zip)
  • 0.13.1(Nov 26, 2019)

    Bufixes

    • Fixes that _ was marked as invalid by VagueImportViolation
    • Fixes that docs for VagueImportViolation were misleading
    • Fixes invalid docs for BracketBlankLineViolation #1020
    • Add more complex example to ParametersIndentationViolation #1021

    Misc

    • Now our GitHub Action can be used to leave PR review comments
    Source code(tar.gz)
    Source code(zip)
  • 0.13.0(Nov 18, 2019)

    This is a huge release that was created during the Hactoberfest season. It would have been impossible without the huge help from our awesome contributors. Thanks a lot to everyone!

    This release is not focused on any particular area. It features a lot of new rules from different categories.

    Features

    • Adds cognitive complexity metric, introduced by cognitive_complexity
    • Adds docstrings linter darglint
    • Updates pep8-naming and flake8-comprehensions
    • WPS431 now allow customize whitelist via nested-classes-whitelist setting
    • Forbids to have invalid strings in stared expressions like **{'@': 1}
    • Forbids to use implicit primitive values in a form of lambda: 0
    • Forbids to use approximate math constants
    • Forbids to redefine string constants
    • Forbids use of vague import names (e.g. from json import loads)
    • Makes OveruseOfNoqaCommentViolation configurable via --max-noqa-comments
    • Forbid incorrectly swapped variables
    • Forbids to use redundant subscripts (e.g., [0:7] or [3:None])
    • Allows super() as a valid overused expression
    • Forbids to use super() with other methods and properties
    • WPS350 enforces using augmented assign pattern
    • Forbids unnecessary literals
    • WPS525 forbids comparisons where in is compared with single item container
    • Forbids wrong annotations in assignment
    • Forbids using multiline for and while statements
    • WPS113 now can be tweaked with I_CONTROL_CODE setting
    • Adds WPS000 that indicates internal errors
    • Forbids to use implicit yield from
    • Forbids to start lines with .
    • Enforces better &, |, >>, <<, ^ operators usage
    • Forbids incorrect exception order
    • Enforces tuples usage with frozenset constructor
    • Changes how WPS444 works, now we use stricter logic for while and assert
    • Forbids to use yield from with incorrect types
    • Forbids to use consecutive yield expressions
    • Enforces to use .items() in loops
    • Enforces using .get() over key in dict checks
    • Forbids to use and declare float keys in arrays and dictionaries
    • Forbids to use a[len(a) - 1] because it is just a[-1]
    • Forbids too long call chains like foo(a)(b)(c)(d)

    Bugfixes

    • Fixes ImplicitElifViolation false positives on a specific edge cases
    • Fixes --i-control-code setting for BadMagicModuleFunctionViolation
    • Fixes compatibility with flake8 3.8.x
    • Fixes that not not True was not detected as WPS330
    • Fixes addition of MisrefactoredAssignmentViolation check
    • Fixes WrongMagicCommentViolation not catching certain wrong comments
    • Fixes BadMagicModuleFunctionViolation false positives on class-level methods
    • Fixes InconsistentReturnViolation false positives on nested functions
    • Fixes that --i-dont-control-code was not present in command line options
    • Fixes BlockVariableVisitor false positives on a properties
    • Fixes that // was not recognised as a math operation
    • Fixes false positive BlockAndLocalOverlapViolation on annotations without value assign
    • Fixes bug when x and not x was not detected as the similar conditions by WPS408
    • Fixed that 1.0 and 0.1 were treated as magic numbers

    Misc

    • Improves Github Action stability
    • Replace scripts/tokens.py and scripts/parse.py with external tools
    • Improves violation code testing
    • Improves testing of .. versionchanged and previous_codes properties
    • Reference isort settings requirement for compliance with WSP318 in docstring
    • Improves tests: we now ensure that each violation with previous codes also has corresponding versions changed in their documentation
    Source code(tar.gz)
    Source code(zip)
  • 0.12.5(Sep 19, 2019)

    Bugfixes

    • We now ignore @overload from BlockAndLocalOverlapViolation
    • Now expressions that reuse block variables are not treated as violations, example: my_var = do_some(my_var)

    Misc

    • Adds Github Action and docs how to use it
    • Adds local Github Action that uses itself for testing
    • Adds official Docker image and docs about it
    Source code(tar.gz)
    Source code(zip)
  • 0.12.4(Aug 29, 2019)

  • 0.12.3(Aug 25, 2019)

    Bugfixes

    • Fixes that formatting was failing sometimes when colours were not available
    • Fixes that 1 / number was not allowed
    • Fixes that % operator was allowed for 0 and 1
    Source code(tar.gz)
    Source code(zip)
  • 0.12.2(Aug 19, 2019)

    Features

    • Adds reveal_type to the list of forbidden functions
    • WPS517 now allows to use non-string keys inside **{}, so this is allowed: Users.objects.get(**{User.USERNAME_FIELD: username})

    Bugfixes

    • Fixes that {**a, **b} was reported as duplicate hash items
    Source code(tar.gz)
    Source code(zip)
  • 0.12.1(Aug 15, 2019)

    Bugfixes

    • Changes radon and pydocstyle versions for better resolution

    Misc

    • Improves README.md with flakehell and nitpick mentions
    • Improves docs all accross the project
    Source code(tar.gz)
    Source code(zip)
  • 0.12.0(Aug 14, 2019)

    In this release we had a little focus on:

    1. Primitives and constants and how to use them
    2. Strings and numbers and how to write them
    3. OOP features
    4. Blocks and code structure, including variable scoping and overlaping variables
    5. Overused expressions and new complexity metrics

    Features

    • Breaking: moves ImplicitInConditionViolation from WPS336 to WPS514
    • Breaking: now ExplicitStringConcatViolation uses WPS336
    • Breaking: moves YieldMagicMethodViolation from WPS435 to WPS611
    • Adds xenon as a dependency, it also checks for cyclomatic complexity, but uses more advanced algorithm with better results
    • Forbids to have modules with too many imported names configured by --max-imported-names option which is 50 by default
    • Forbids to raise StopIteration inside generators
    • Forbids to have incorrect method order inside classes
    • Forbids to make some magic methods async
    • Forbids to use meaningless zeros in float, binary, octal, hex, and expanentional numbers
    • Enforces to use 1e10 instead of 1e+10
    • Enforces to use big letters for hex numbers: 0xAB instead of 0xab
    • Enforces to use r'\n' instead of '\\n'
    • Forbids to have unicode escape characters inside binary strings
    • Forbids to use else if instead of elif
    • Forbids to have too long try bodies, basically try bodies with more than one statement
    • Forbids to overlap local and block variables
    • Forbids to use block variables after the block definitions
    • Changes how WrongSlotsViolation works, now (...) + value is restricted in favor of (..., *value)
    • Forbids to have explicit unhashable types in sets and dicts
    • Forbids to define useless overwritten methods
    • Enforces j prefix over J for complex numbers
    • Forbids overused expressions
    • Forbids explicit 0 division, multiply, pow, addition, and substraction
    • Fordids to pow, multiply, or divide by 1
    • Forbids to use expressions like x + -2, or y - -1, or z -= -1
    • Forbids to multiply lists like [0] * 2
    • Forbids to use variable names like __ and _____
    • Forbids to define unused variables explicitly: _unused = 2
    • Forbids to shadow outer scope variables with local ones
    • Forbids to have too many assert statements in a function
    • Forbids to have explicit string contact: 'a' + some_data, use .format()
    • Now YieldInsideInitViolation is named YieldMagicMethodViolation and it also checks different magic methods in a class
    • Forbids to use assert False and other false-constants
    • Forbids to use while False: and other false-constants
    • Forbids to use open() outside of with
    • Forbids to use type() for compares
    • Forbids to have consecutive expressions with too deep access level
    • Forbids to have too many public instance attributes
    • Forbids to use pointless star operations: print(*[])
    • Forbids to use range(len(some)), use enumerate(some) instead
    • Forbids to use implicit sum() calls and replace them with loops
    • Forbids to compare with the falsy constants like if some == []:

    Bugfixes

    • Bumps flake8-eradicate version and solves attrs incompatible versions issue
    • Bumps flake8-dosctrings veresion and solved pydocstyle issue
    • Fixes TryExceptMultipleReturnPathViolation not tracking else and finally returns at the same time
    • Fixes how TryExceptMultipleReturnPathViolation works: now handles break and raise statements as well
    • Fixes WrongLoopIterTypeViolation not triggering for generator expressions and empty tuples
    • Fixes WrongLoopIterTypeViolation not triggering for numbers (including negative), booleans, None
    • Fixes WrongLoopIterTypeViolation position
    • Fixes WrongLoopIterTypeViolation not triggering for compehensions
    • Fixes WrongSlotsViolation not triggering for comprehensions and incorrect __slots__ names and types
    • Fixes WrongSlotsViolation not triggering for invalid python identifiers like __slots__ = ('123_slot',)
    • Fixes WrongSlotsViolation triggering for subscripts
    • Fixes NestedClassViolation and NestedFunctionViolation not reporting when placed deeply inside other nodes
    • Fixes when WrongUnpackingViolation was not raised for async for and async with nodes
    • Fixes when WrongUnpackingViolation was not raised for comprehensions
    • Fixes that x, y, z = x, z, y was not recognized as ReassigningVariableToItselfViolation
    • Fixes that {1, True, 1.0} was not recognised as a set with duplicates
    • Fixes that {(1, 2), (1, 2)} was not recognised as a set with duplicates
    • Fixes that {*(1, 2), *(1, 2)} was not recognised as a set with duplicates
    • Fixes that {1: 1, True: 1} was not recognised as a dict with duplicates
    • Fixes that complex numbers were always treated like magic, now 1j is allowed
    • Fixes that 0.0 was treated as a magic number
    • Fixes that it was possible to use _ in module body
    • Fixes WrongBaseClassViolation not triggering for nested nodes like class Test(call().length):
    • Fixes ComplexDefaultValueViolation not triggering for nested nodes like def func(arg=call().attr)
    • Fixes TooShortNameViolation was not triggering for _x and x_
    • Fixes that some magic method were allowed to be generators
    • Fixes that some magic method were allowed to contain yield from
    • Fixes bug when some correct noqa: comments were reported as incorrect
    • Fixes bug when some else: return were not reported as incorrect
    • Fixes bug when WPS507 sometimes were raising ValueError
    • Fixes bug when return None was not recognized as inconsistent

    Misc

    • Adds styles/ directory with style presets for tools we use and recommend
    • Adds bellybutton to the list of other linters
    • Documents how to use nitpick to sync the configuration
    • Documents how to use flakehell to create baselines for legacy integrations
    • Improves tests for binary, octal, hex, and expanetional numbers
    • Adds new xenon CI check
    • Now handles exceptions in our own code, hope to never see them!
    • Now uses coverage checks in deepsource
    • Now @alias checks that all aliases are valid
    • Changes how presets are defined
    • Improves how DirectMagicAttributeAccessViolation is tested
    • Refactors a lot of tests to tests ast.Starred
    • Refactors a lot of tests to have less tests with the same logical coverage
    • We now use import-linter instead of layer-linter
    • Adds docs about CI integration
    • Now wheels are not universal
    • Updates docs about snake_case in Enum fields
    • Updates docs about WPS400 and incorrect line number
    Source code(tar.gz)
    Source code(zip)
  • 0.11.1(Jul 18, 2019)

  • 0.11.0(Jul 18, 2019)

    We had a really big problem: all violations inside best_practices was messed up together with no clear structure.

    We had to fix it before it is too late. So, we broke existing error codes. And now we can promise not to do it ever again.

    We also have this nice migration guide for you to rename your violations with a script.

    Features

    • Breaking: replaces Z error code to WPS code
    • Breaking: creates new violation group refactoring.py
    • Breaking: creates new violation group oop.py
    • Breaking: moving a lot of violations from best_practices to refactoring, oop, and consistency
    • Adds new wemake formatter (using it now by default)

    Bugfixes

    • Fixes error message of OverusedStringViolation for empty strings
    • Now does not count string annotations as strings for OverusedStringViolation
    • Fixes InconsistentReturnVariableViolation was raised twice

    Misc

    • Adds migration guide to 0.11
    • Improves legacy guide
    • Adds --show-source to the default recommended configuration
    • Adds better docs about auto-formatters
    • Adds autopep8 to CI to make sure that wps is compatible with it
    • Ensures that --diff mode works for flake8
    • Renames Incorrect to Wrong where possible
    • Renames IncorrectlyNestedTernaryViolation to NestedTernaryViolation
    • Renames IncorectLoopIterTypeViolation to WrongLoopIterTypeViolation
    Source code(tar.gz)
    Source code(zip)
  • 0.10.0(Jul 13, 2019)

    This release is mostly targeted at writing better compares and conditions. We introduce a lot of new rules related to this topic improving: consistency, complexity, and general feel from your code.

    In this release we have ported a lot of existing pylint rules, big cudos to the developers of this wonderful tool.

    Features

    • Adds flake8-executable as a dependency
    • Adds flake8-rst-docstrings as a dependency
    • Validates options that are passed with flake8
    • Forbids to use module level mutable constants
    • Forbids to over-use strings
    • Forbids to use breakpoint function
    • Limits yield tuple lengths
    • Forbids to have too many await statements
    • Forbids to subclass lowercase builtins
    • Forbids to have useless lambdas
    • Forbids to use len(sized) > 0 and if len(sized) style checks
    • Forbids to use repeatable conditions: flag or flag
    • Forbids to write conditions like not some > 1
    • Forbids to use heterogenous compares like x == x > 0
    • Forbids to use complex compare with several items (>= 3)
    • Forbids to have class variables that are shadowed by instance variables
    • Forbids to use ternary expressions inside if conditions
    • Forces to use ternary instead of ... and ... or ... expression
    • Forces to use c < b < a instead of a > b and b > c
    • Forces to use c < b < a instead of a > b > c
    • Forbids to use explicit in [] and in (), use sets or variables instead
    • Forces to write isinstance(some, (A, B)) instead of isinstance(some, A) or isinstance(some, B)
    • Forbids to use isinstance(some (A,))
    • Forces to merge a == b or a == c into a in {b, c} and to merge a != b and a != c into a not in {b, c}

    Bugfixes

    • Fixes incorrect line number for Z331
    • Fixes that Z311 was not raising for multiple not in cases
    • Fixes a bunch of bugs for rules working with Assign and not AnnAssign
    • Fixes that continue was not triggering UselessReturningElseViolation

    Misc

    • Renames logics/ to logic/ since it is grammatically correct
    • Renames Redundant to Useless
    • Renames Comparison to Compare
    • Renames WrongConditionalViolation to ConstantConditionViolation
    • Renames ComplexDefaultValuesViolation to ComplexDefaultValueViolation
    • Refactors UselessOperatorsVisitor
    • Adds compat/ package, getting ready for python3.8
    • Adds Makefile
    • A lot of minor dependency updates
    Source code(tar.gz)
    Source code(zip)
  • 0.9.1(Jul 12, 2019)

  • 0.9.0(Jun 20, 2019)

    This is mostly a supporting release with several new features and lots of bug fixes.

    Features

    • Forbids to use magic module methods __getattr__ and __dir__
    • Forbids to use multiline conditions
    • Forbids local variables that are only used in return statements

    Bugfixes

    • Fixes module names for modules like io.py
    • Fixes false positive Z310 for numbers like 0xE
    • Fixes false positive for compare ordering with await
    • Fixes problem with missing _allowed_left_nodes
    • Fixes problem false positive for Z121 when using _ for unused var names
    • Fixes false positive for negative number in default values
    • Fixes error text for ComplexDefaultValuesViolation
    • Fixes problem with false positive for Z459 when a default value is an Ellipsis

    Misc

    • Adds py.typed file in case someone will import our code, now it will have types
    • Adds several missing @final decorators
    • Enforces typing support
    • Refactors how typing_extensions package is used
    • Adds docs about black
    • Adds big "Star" button
    • Multiple dependencies update
    • Better exclude rule for flake8 check
    • Removed warnings from pytest
    Source code(tar.gz)
    Source code(zip)
  • 0.8.1(Jun 13, 2019)

  • 0.8.0(Mar 3, 2019)

    Features

    • Updates flake8 to 3.7+
    • Adds flake8-annotations-complexity as a dependency, forbids complex annotations
    • Forbids to use redundant +, ~, not, and - operators before numbers
    • Forbids to use complex default values
    • Forbids to use anything rather than names in for loop vars definitions
    • Forbids to use anything rather than names in with block vars definitions
    • Forbids to use anything rather than names in comprehension vars definitions
    • Forbids to use direct magic attributes access
    • Forbids to use negated conditions
    • Forbids to use too many # pragma: no cover comments
    • Forbids to use nested try blocks

    Bugfixes

    • Fixes problems with empty lines after magic comments, see #492
    • Fixes error message for del keyword: it is now just 'del' not 'delete'

    Misc

    • Removes flake8-per-file-ignores plugin, since flake8 now handles it
    • Removes flake8-type-annotations plugin, since flake8 now handles it
    • Improves docs for WrongKeywordViolation
    • Improves docs for EmptyLineAfterCodingViolation
    • Improves docs for ProtectedAttributeViolation
    • Adds docs about .pyi files
    Source code(tar.gz)
    Source code(zip)
  • 0.7.1(Feb 8, 2019)

    Bugfixes

    • Allows Generic[SomeType] to be a valid superclass
    • Forces to use flake8 version 3.6 instead of 3.7

    Misc

    • Improves docs about using # type: some comment in for loops
    Source code(tar.gz)
    Source code(zip)
  • 0.7.0(Jan 23, 2019)

    Features

    • Now raising a violation for every bool non-keyword argument and showing better error message
    • Changes how max-arguments are counted. Now self, cls, and mcs count as real arguments
    • Forbids to use yield inside comprehensions
    • Forbids to have single line triple-quoted string assignments
    • Forbids to have same items in set literals
    • Forbids to subclass BaseException
    • Forbids to use simplifiable if expressions and nodes
    • Forbids to have incorrect nodes in class body
    • Forbids to have methods without any arguments
    • Forbids to have incorrect base classes nodes
    • Enforces consistent __slots__ syntax
    • Forbids to use names with trailing _ without a reason
    • Forbids to use super() with arguments or outside of methods
    • Forbids to have too many except cases
    • Enforces to have an empty line after coding comment
    • Forbids to use too many # noqa comments
    • Forbids to use variables declared as unused
    • Forbids to use redundant else blocks
    • Forbids to use inconsistent return and yield statements
    • Forbids to use multiple return path in try/expect/finally
    • Forbids to use implicit string concatenation
    • Forbids to have useless continue nodes inside the loops
    • Forbids to have useless nodes
    • Forbids to have useless raise statements
    • Adds params and parameters to black-listed names

    Bugfixes

    • Fixes a lot of rules that were ignoring Bytes node as constant type
    • Fixes location of the BooleanPositionalArgumentViolation
    • Fixes argument count issue with async functions
    • Fixes WrongConditionalVisitor not detecting tuple as constants
    • Fixes WrongConditionalVisitor not detecting negative numbers as constants
    • Fixes some magic number that were not detected based on their location
    • Fixes error when regular functions named as blacklisted magic methods were forbidden, now we check for methods only
    • Fixes error when strings like U'some' was not triggering unicode violation
    • Fixes error when string like U'some' was not triggering modifier violation

    Misc

    • Adds safety and other dependency checks to the CI process
    • Improves tests: now tokenize works differently inside tests
    • Improves tests: now testing more brackets cases aka "magic coverage bug"
    • Improves docs: adds new badge about our code style
    • Refactoring: trying to use astor where possible to simplify the codebase
    • Refactoring: introduces some new transformations
    • Refactoring: now we do not have any magical text casts for violations
    • Improves tests: changes how flake8 is executed, now it is twice as fast
    • Improves docs: now linting conf.py with flake8
    • Improves tests: now we check that ignored violation are raised with noqa
    • Improves docs: we have added a special graph to show our architecure
    • Improves docs: we now have a clean page for checker without extra junk
    • Improves docs: we now have a tutorial for creating new rules
    • Refactoring: moves presets package to the root
    • Improves tests: we now lint our layered architecure with layer-lint
    Source code(tar.gz)
    Source code(zip)
  • 0.6.3(Jan 23, 2019)

It's not just a linter that annoys you!

README for Pylint - https://pylint.pycqa.org/ Professional support for pylint is available as part of the Tidelift Subscription. Tidelift gives softwa

Python Code Quality Authority 4.4k Jan 4, 2023
Mylint - My really simple rendition of how a linter works.

mylint My really simple rendition of how a linter works. This original version was written for my AST article. Since then I've added tests and turned

Tushar Sadhwani 2 Dec 29, 2021
Simple Python style checker in one Python file

pycodestyle (formerly called pep8) - Python style guide checker pycodestyle is a tool to check your Python code against some of the style conventions

Python Code Quality Authority 4.7k Jan 1, 2023
Optional static typing for Python 3 and 2 (PEP 484)

Mypy: Optional Static Typing for Python Got a question? Join us on Gitter! We don't have a mailing list; but we are always happy to answer questions o

Python 14.4k Jan 8, 2023
A plugin for Flake8 finding likely bugs and design problems in your program. Contains warnings that don't belong in pyflakes and pycodestyle.

flake8-bugbear A plugin for Flake8 finding likely bugs and design problems in your program. Contains warnings that don't belong in pyflakes and pycode

Python Code Quality Authority 869 Dec 30, 2022
A Python Parser

parso - A Python Parser Parso is a Python parser that supports error recovery and round-trip parsing for different Python versions (in multiple Python

Dave Halter 520 Dec 26, 2022
A simple program which checks Python source files for errors

Pyflakes A simple program which checks Python source files for errors. Pyflakes analyzes programs and detects various errors. It works by parsing the

Python Code Quality Authority 1.2k Dec 30, 2022
Performant type-checking for python.

Pyre is a performant type checker for Python compliant with PEP 484. Pyre can analyze codebases with millions of lines of code incrementally – providi

Facebook 6.2k Jan 4, 2023
A static type analyzer for Python code

pytype - ?? ✔ Pytype checks and infers types for your Python code - without requiring type annotations. Pytype can: Lint plain Python code, flagging c

Google 4k Dec 31, 2022
Static type checker for Python

Static type checker for Python Speed Pyright is a fast type checker meant for large Python source bases. It can run in a “watch” mode and performs fas

Microsoft 9.2k Jan 3, 2023
Tool to check the completeness of MANIFEST.in for Python packages

check-manifest Are you a Python developer? Have you uploaded packages to the Python Package Index? Have you accidentally uploaded broken packages with

Marius Gedminas 270 Dec 26, 2022
Flake8 plugin that checks import order against various Python Style Guides

flake8-import-order A flake8 and Pylama plugin that checks the ordering of your imports. It does not check anything else about the imports. Merely tha

Python Code Quality Authority 270 Nov 24, 2022
Flake8 extension for checking quotes in python

Flake8 Extension to lint for quotes. Major update in 2.0.0 We automatically encourage avoiding escaping quotes as per PEP 8. To disable this, use --no

Zachary Heller 157 Dec 13, 2022
Check for python builtins being used as variables or parameters

Flake8 Builtins plugin Check for python builtins being used as variables or parameters. Imagine some code like this: def max_values(list, list2):

Gil Forcada Codinachs 98 Jan 8, 2023
flake8 plugin to run black for checking Python coding style

flake8-black Introduction This is an MIT licensed flake8 plugin for validating Python code style with the command line code formatting tool black. It

Peter Cock 146 Dec 15, 2022
Custom Python linting through AST expressions

bellybutton bellybutton is a customizable, easy-to-configure linting engine for Python. What is this good for? Tools like pylint and flake8 provide, o

H. Chase Stevens 249 Dec 31, 2022
Unbearably fast O(1) runtime type-checking in pure Python.

Look for the bare necessities, the simple bare necessities. Forget about your worries and your strife. — The Jungle Book.

beartype 1.4k Jan 1, 2023
Naming Convention checker for Python

PEP 8 Naming Conventions Check your code against PEP 8 naming conventions. This module provides a plugin for flake8, the Python code checker. (It repl

Python Code Quality Authority 411 Dec 23, 2022
Code audit tool for python.

Pylama Code audit tool for Python and JavaScript. Pylama wraps these tools: pycodestyle (formerly pep8) © 2012-2013, Florent Xicluna; pydocstyle (form

Kirill Klenov 967 Jan 7, 2023