mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-07 22:44:27 +08:00
hasattr test for static analysis, it's a common idiom.
This commit is contained in:
@@ -49,3 +49,18 @@ try:
|
|||||||
#! 4 attribute-error
|
#! 4 attribute-error
|
||||||
str.not_existing
|
str.not_existing
|
||||||
except [AttributeError]: pass
|
except [AttributeError]: pass
|
||||||
|
|
||||||
|
|
||||||
|
# -----------------
|
||||||
|
# kind of similar: hasattr
|
||||||
|
# -----------------
|
||||||
|
|
||||||
|
if hasattr(object, 'undefined'):
|
||||||
|
str.undefined
|
||||||
|
str.upper
|
||||||
|
#! 4 attribute-error
|
||||||
|
str.undefined2
|
||||||
|
else:
|
||||||
|
str.upper
|
||||||
|
#! 4 attribute-error
|
||||||
|
str.undefined
|
||||||
|
|||||||
Reference in New Issue
Block a user