Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional parameters for ClassDef #19

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions pylint_flask_sqlalchemy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,19 @@ def transform(node: NodeNG) -> None:
does not raise an error, so you think your code (and ours) works, but it's not :-(
So we need to write tests that fails to make sure our plugin works.
"""
params = dict(col_offset=0, parent=node, end_lineno=None, end_col_offset=None)

if node.name == "SQLAlchemy":
import sqlalchemy
import sqlalchemy.orm

for module in sqlalchemy, sqlalchemy.orm:
for key in sorted(module.__all__, key=sort_module_keys):
if key not in FLASK_SQLALCHEMY_WRAPS:
node.locals[key] = [ClassDef(key, None)]
node.locals[key] = [ClassDef(key, None, **params)]
else:
node.locals[key] = [
ClassDef(key, None),
ClassDef(key, None, **params),
node.locals["Query"]
]
elif node.name == "scoped_session":
Expand All @@ -57,9 +59,9 @@ def transform(node: NodeNG) -> None:
for key in sorted(dir(Session), reverse=True):
# `query` is in fact a proxy to `query_property`
if key == "query":
node.locals[key] = [ClassDef(key, None), node.locals["query_property"]]
node.locals[key] = [ClassDef(key, None, **params), node.locals["query_property"]]
else:
node.locals[key] = [ClassDef(key, None)]
node.locals[key] = [ClassDef(key, None, **params)]


MANAGER.register_transform(ClassDef, transform)