Giter Club home page Giter Club logo

pylint_flask_sqlalchemy's Introduction

Pylint Flask SQLAlchemy

PyPI Workflow Downloads

About

pylint_flask_sqlalchemy is a Pylint to improve static code analysis of Flask-SQLAlchemy based projects.

pylint_flask_sqlalchemy is now hosted on GitHub: https://github.com/anybox/pylint_flask_sqlalchemy

Installation

pip install pylint_flask_sqlalchemy

And tell Pylint to --load-plugins pylint_flask_sqlalchemy.

Usage

Here's a simple flask application:

"""app.py"""
from flask import Flask
from flask_sqlalchemy import SQLAlchemy

app = Flask(__name__)
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:////tmp/test.db"
db = SQLAlchemy(app)


class Group(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(80), unique=True, nullable=False)

    def __repr__(self):
        return f"<Group {self.name}>"


class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(80), unique=True, nullable=False)
    group = db.relationship(Group)

    def __repr__(self):
        return f"<User {self.username}>"

user = User(username="test")
db.session.add(user)
db.session.commit()

Without the plugin ๐Ÿ˜“

pylint app.py

app.py:11:9: E1101: Instance of 'SQLAlchemy' has no 'Column' member (no-member)
app.py:11:19: E1101: Instance of 'SQLAlchemy' has no 'Integer' member (no-member)
app.py:12:11: E1101: Instance of 'SQLAlchemy' has no 'Column' member (no-member)
app.py:12:21: E1101: Instance of 'SQLAlchemy' has no 'String' member (no-member)
app.py:19:9: E1101: Instance of 'SQLAlchemy' has no 'Column' member (no-member)
app.py:19:19: E1101: Instance of 'SQLAlchemy' has no 'Integer' member (no-member)
app.py:20:15: E1101: Instance of 'SQLAlchemy' has no 'Column' member (no-member)
app.py:20:25: E1101: Instance of 'SQLAlchemy' has no 'String' member (no-member)
app.py:21:12: E1101: Instance of 'SQLAlchemy' has no 'relationship' member (no-member)
app.py:28:0: E1101: Instance of 'scoped_session' has no 'add' member (no-member)
app.py:29:0: E1101: Instance of 'scoped_session' has no 'commit' member (no-member)

----------------------------------------------------------------------
Your code has been rated at -18.95/10 (previous run: 10.00/10, -28.95)

With pylint_flask_sqlalchemy ๐Ÿฅณ

pylint --load-plugins pylint_flask_sqlalchemy app.py

----------------------------------------------------------------------
Your code has been rated at 10.00/10 (previous run: -13.08/10, +23.08)

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.