Code Monkey home page Code Monkey logo

flake8-super-call's Introduction

Flake8 super call Checker

flake8-super-call is a Flake8 extension that checks Python methods for anti-pattern super calls.

When calling super in a derived class, passing self.__class__ to super() can give the wrong starting point to search for methods, and will end up calling its own method again. More details on this Stack Overflow question.

Installation

Install from PyPI using pip:

$ pip install flake8-super-call

The extension will be activated automatically by flake8. You can verify that it has been loaded by inspecting the flake8 --version:

$ flake8 --version
3.5.0 (flake8_super_call: 1.0.0, mccabe: 0.6.1, pycodestyle: 2.3.1, pyflakes: 1.6.0) CPython 2.7.10 on Darwin

Error Codes

This extension adds one new error code:

  • S777: Cannot use self.__class__ as first argument of super() call

flake8-super-call's People

Contributors

dragosoprica avatar

Watchers

James Cloos avatar  avatar

flake8-super-call's Issues

Python 3 super calls style

Hi! I wanted to implement a similar flake8 plugin to check for a codebase that has now migrated to Python 3, which supports not passing anything:

class MyClass(ParentClass):
    def __init__(self):
         super().__init__()

My idea was to create a plugin to enforce the new style. It feels like it belongs in flake8-super-call, given its name. It could be implemented as a separate check and could be disabled if running under Python 2 or for codebase that should still support Python 2.

Are you interested in adding this? Are you still maintaining this package? If so, I'll send a pull request, otherwise, I'll work on a fork.

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.