{"id":9221,"library":"pylint-flask","title":"pylint-flask","description":"pylint-flask is a Pylint plugin designed to improve static code analysis for Flask applications. It helps Pylint correctly interpret Flask-specific patterns, particularly addressing issues related to the `flask.ext` import style (which has since been deprecated in Flask itself) and other dynamic attributes in Flask extensions. The current version is 0.6, released in January 2019, indicating a maintenance phase with infrequent updates.","status":"maintenance","version":"0.6","language":"en","source_language":"en","source_url":"https://github.com/jschaf/pylint-flask","tags":["pylint","flask","linter","static analysis","plugin","code quality"],"install":[{"cmd":"pip install pylint-flask","lang":"bash","label":"Install `pylint-flask`"}],"dependencies":[{"reason":"pylint-flask is a plugin for Pylint and requires it to function.","package":"pylint","optional":false},{"reason":"pylint-flask is designed to analyze Flask applications.","package":"Flask","optional":false}],"imports":[{"note":"pylint-flask is loaded as a Pylint plugin via the command line, not imported directly into Python code.","wrong":"from pylint_flask import ...","symbol":"pylint_flask","correct":"pylint --load-plugins pylint_flask your_module.py"}],"quickstart":{"code":"# my_flask_app.py\nfrom flask import Flask\nfrom flask_wtf import CSRFProtect # Example: direct import for Flask-WTF\n\napp = Flask(__name__)\napp.config['SECRET_KEY'] = 'a-very-secret-key'\ncsrf = CSRFProtect(app)\n\n@app.route('/')\ndef index():\n    return 'Hello, Flask!'\n\n# To run pylint with the plugin:\n# pylint --load-plugins pylint_flask my_flask_app.py","lang":"python","description":"Install `pylint-flask` and then run Pylint, explicitly loading the plugin with the `--load-plugins` flag. This example shows a minimal Flask app and how to lint it. For Flask extensions, ensure you are using direct imports (e.g., `from flask_wtf import ...`) as the `flask.ext` pattern is deprecated in modern Flask versions."},"warnings":[{"fix":"For new projects or updated Flask versions (2.0+), migrate to direct imports for all Flask extensions (e.g., `from flask_sqlalchemy import SQLAlchemy` instead of `from flask.ext import sqlalchemy`). If you maintain older code, `pylint-flask` can still be beneficial, but be aware of the `flask.ext` deprecation.","message":"The `flask.ext` import pattern, which `pylint-flask` was primarily designed to address, was officially deprecated and removed in Flask 2.0. If you are using Flask 2.0 or newer, you should be using direct imports for extensions (e.g., `from flask_wtf import ...`). `pylint-flask`'s core functionality for `flask.ext` may be less relevant or even cause unexpected linting behavior with modern Flask applications.","severity":"breaking","affected_versions":"<= Flask 1.x (primary target of plugin), >= Flask 2.0 (impact on relevance)"},{"fix":"For Flask-SQLAlchemy specific `no-member` issues, consider using `pylint-flask-sqlalchemy` in addition to `pylint-flask`. Otherwise, you may need to disable specific `no-member` checks globally, locally, or add `--generated-members` to your Pylint configuration.","message":"While `pylint-flask` helps with generic Flask patterns, it may not fully resolve `E1101: no-member` errors for specific Flask extensions like Flask-SQLAlchemy or Flask-Migrate where attributes are dynamically added to objects. You might still encounter false positives for `db.Column`, `db.Integer`, etc.","severity":"gotcha","affected_versions":"All versions of pylint-flask and related Flask extensions"},{"fix":"If you are certain the import is necessary (e.g., for a decorator to register a route), you can explicitly tell Pylint to ignore the warning for that line using `# pylint: disable=unused-import` or configure Pylint to ignore this check for specific patterns.","message":"Pylint might report `W0611: Unused import <module_name>` even when an import is indirectly used, for example, by a decorator or if `pylint-flask` transforms an import, but the original reference isn't explicitly used elsewhere in the file.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Ensure `pylint-flask` is installed and loaded when running Pylint: `pylint --load-plugins pylint_flask your_module.py`. For modern Flask, prefer direct imports like `from flask_wtf import CSRFProtect`.","cause":"Pylint, without the plugin, does not understand the historical `flask.ext` import mechanism used for Flask extensions.","error":"E: No name 'ext' in module 'flask' (no-name-in-module)"},{"fix":"Load the `pylint-flask` plugin: `pylint --load-plugins pylint_flask your_module.py`. If using Flask 2.0+, update your code to use direct imports (e.g., `import flask_wtf` or `from flask_wtf import ...`).","cause":"Similar to `no-name-in-module`, Pylint's import resolver fails to find modules imported via the `flask.ext` namespace.","error":"E: No module named flask.ext.wtf"},{"fix":"Install and load `pylint-flask-sqlalchemy` alongside `pylint-flask` (`pip install pylint-flask-sqlalchemy` then `pylint --load-plugins pylint_flask,pylint_flask_sqlalchemy your_module.py`). Alternatively, you can add `--generated-members=Column,Integer,String` (etc.) to your Pylint configuration or disable `no-member` for specific lines/modules.","cause":"Pylint cannot statically determine members added dynamically by extensions like Flask-SQLAlchemy to base objects.","error":"E1101: Instance of 'SQLAlchemy' has no 'Column' member (no-member)"}]}