From de138e9114fd2f7999698b0a074fe606023c10ed Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Wed, 3 Jul 2019 09:20:05 -0700 Subject: [PATCH] Improve a bit of dataclasses support, so at least the attributes can be seen see #1213 --- jedi/plugins/stdlib.py | 4 ++++ test/completion/decorators.py | 3 +++ test/completion/pep0526_variables.py | 10 ++++++++++ 3 files changed, 17 insertions(+) diff --git a/jedi/plugins/stdlib.py b/jedi/plugins/stdlib.py index 52413a29..149e7e6d 100644 --- a/jedi/plugins/stdlib.py +++ b/jedi/plugins/stdlib.py @@ -599,4 +599,8 @@ _implemented = { # being used instead. This only matters for 3.7+. '_alias': lambda obj, arguments: NO_CONTEXTS, }, + 'dataclasses': { + # For now this works at least better than Jedi trying to understand it. + 'dataclass': lambda obj, arguments: NO_CONTEXTS, + }, } diff --git a/test/completion/decorators.py b/test/completion/decorators.py index 043ed0bf..a61487a3 100644 --- a/test/completion/decorators.py +++ b/test/completion/decorators.py @@ -310,11 +310,14 @@ follow_statement(1) # class decorators should just be ignored @should_ignore class A(): + x = 3 def ret(self): return 1 #? int() A().ret() +#? int() +A().x # ----------------- diff --git a/test/completion/pep0526_variables.py b/test/completion/pep0526_variables.py index 37e7ae71..6af77d91 100644 --- a/test/completion/pep0526_variables.py +++ b/test/completion/pep0526_variables.py @@ -103,3 +103,13 @@ d.var_class1 d.var_class2 #? [] d.int + + + +import dataclasses +@dataclasses.dataclass +class DC: + name: int = 1 + +#? int() +DC().name