summaryrefslogtreecommitdiff
path: root/tests/testdata
diff options
context:
space:
mode:
authorDaniƫl van Noord <13665637+DanielNoord@users.noreply.github.com>2022-01-26 19:48:31 +0100
committerGitHub <noreply@github.com>2022-01-26 19:48:31 +0100
commit74710868d717b94898a72f148e16fa833c1e0593 (patch)
treefe4d8c3627a289e308f4d21048c3d1b7cdaefbf3 /tests/testdata
parent7cde9994b381dfa8ae73ea25fced297e3f9f0afe (diff)
downloadastroid-git-74710868d717b94898a72f148e16fa833c1e0593.tar.gz
Fix crash on ``Super.getattr`` for previously uninferable attributes (#1370)
Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
Diffstat (limited to 'tests/testdata')
-rw-r--r--tests/testdata/python3/data/max_inferable_limit_for_classes/main.py38
-rw-r--r--tests/testdata/python3/data/max_inferable_limit_for_classes/nodes/roles.py82
-rw-r--r--tests/testdata/python3/data/max_inferable_limit_for_classes/other_funcs.py31
3 files changed, 151 insertions, 0 deletions
diff --git a/tests/testdata/python3/data/max_inferable_limit_for_classes/main.py b/tests/testdata/python3/data/max_inferable_limit_for_classes/main.py
new file mode 100644
index 00000000..2588d916
--- /dev/null
+++ b/tests/testdata/python3/data/max_inferable_limit_for_classes/main.py
@@ -0,0 +1,38 @@
+"""This example is based on sqlalchemy.
+
+See https://github.com/PyCQA/pylint/issues/5679
+"""
+from other_funcs import FromClause
+
+from .nodes import roles
+
+
+class HasMemoized(object):
+ ...
+
+
+class Generative(HasMemoized):
+ ...
+
+
+class ColumnElement(
+ roles.ColumnArgumentOrKeyRole,
+ roles.BinaryElementRole,
+ roles.OrderByRole,
+ roles.ColumnsClauseRole,
+ roles.LimitOffsetRole,
+ roles.DMLColumnRole,
+ roles.DDLConstraintColumnRole,
+ roles.StatementRole,
+ Generative,
+):
+ ...
+
+
+class FunctionElement(ColumnElement, FromClause):
+ ...
+
+
+class months_between(FunctionElement):
+ def __init__(self):
+ super().__init__()
diff --git a/tests/testdata/python3/data/max_inferable_limit_for_classes/nodes/roles.py b/tests/testdata/python3/data/max_inferable_limit_for_classes/nodes/roles.py
new file mode 100644
index 00000000..2f58f1b5
--- /dev/null
+++ b/tests/testdata/python3/data/max_inferable_limit_for_classes/nodes/roles.py
@@ -0,0 +1,82 @@
+class SQLRole(object):
+ ...
+
+
+class UsesInspection(object):
+ ...
+
+
+class AllowsLambdaRole(object):
+ ...
+
+
+class ColumnArgumentRole(SQLRole):
+ ...
+
+
+class ColumnArgumentOrKeyRole(ColumnArgumentRole):
+ ...
+
+
+class ColumnListRole(SQLRole):
+ ...
+
+
+class ColumnsClauseRole(AllowsLambdaRole, UsesInspection, ColumnListRole):
+ ...
+
+
+class LimitOffsetRole(SQLRole):
+ ...
+
+
+class ByOfRole(ColumnListRole):
+ ...
+
+
+class OrderByRole(AllowsLambdaRole, ByOfRole):
+ ...
+
+
+class StructuralRole(SQLRole):
+ ...
+
+
+class ExpressionElementRole(SQLRole):
+ ...
+
+
+class BinaryElementRole(ExpressionElementRole):
+ ...
+
+
+class JoinTargetRole(AllowsLambdaRole, UsesInspection, StructuralRole):
+ ...
+
+
+class FromClauseRole(ColumnsClauseRole, JoinTargetRole):
+ ...
+
+
+class StrictFromClauseRole(FromClauseRole):
+ ...
+
+
+class AnonymizedFromClauseRole(StrictFromClauseRole):
+ ...
+
+
+class ReturnsRowsRole(SQLRole):
+ ...
+
+
+class StatementRole(SQLRole):
+ ...
+
+
+class DMLColumnRole(SQLRole):
+ ...
+
+
+class DDLConstraintColumnRole(SQLRole):
+ ...
diff --git a/tests/testdata/python3/data/max_inferable_limit_for_classes/other_funcs.py b/tests/testdata/python3/data/max_inferable_limit_for_classes/other_funcs.py
new file mode 100644
index 00000000..f737fbf5
--- /dev/null
+++ b/tests/testdata/python3/data/max_inferable_limit_for_classes/other_funcs.py
@@ -0,0 +1,31 @@
+from operator import attrgetter
+
+from .nodes import roles
+
+
+class HasCacheKey(object):
+ ...
+
+
+class HasMemoized(object):
+ ...
+
+
+class MemoizedHasCacheKey(HasCacheKey, HasMemoized):
+ ...
+
+
+class ClauseElement(MemoizedHasCacheKey):
+ ...
+
+
+class ReturnsRows(roles.ReturnsRowsRole, ClauseElement):
+ ...
+
+
+class Selectable(ReturnsRows):
+ ...
+
+
+class FromClause(roles.AnonymizedFromClauseRole, Selectable):
+ c = property(attrgetter("columns"))