src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Annotations/AnnotationsFutureVisitor.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9276
e6748a5e24b9
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Annotations/AnnotationsFutureVisitor.py	Wed Jul 13 11:16:20 2022 +0200
+++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Annotations/AnnotationsFutureVisitor.py	Wed Jul 13 14:55:47 2022 +0200
@@ -19,6 +19,7 @@
     """
     Class implementing a node visitor to check __future__ imports.
     """
+
     SimplifyableTypes = (
         "DefaultDict",
         "Deque",
@@ -31,30 +32,30 @@
         "Union",
         "Type",
     )
-    
+
     def __init__(self):
         """
         Constructor
         """
         super().__init__()
-        
+
         self.__typingAliases = []
         self.__importsFutureAnnotations = False
-        
+
         # e.g. from typing import List, typing.List, t.List
         self.__typingImports = []
-    
+
     def visit_Import(self, node):
         """
         Public method to check imports for typing related stuff.
-        
+
         This looks like:
         import typing
         or
         import typing as t
-        
+
         typing or t will be added to the list of typing aliases.
-        
+
         @param node reference to the AST Import node
         @type ast.Import
         """
@@ -63,9 +64,9 @@
                 self.__typingAliases.append("typing")
             if alias.asname is not None:
                 self.__typingAliases.append(alias.asname)
-        
+
         self.generic_visit(node)
-    
+
     def visit_ImportFrom(self, node):
         """
         Public method to detect the 'from __future__ import annotations'
@@ -73,7 +74,7 @@
 
         If 'from typing import ...' is used, add simplifiable names that were
         imported.
-        
+
         @param node reference to the AST ImportFrom node
         @type ast.ImportFrom
         """
@@ -88,48 +89,48 @@
                     self.__typingImports.append(alias.name)
 
         self.generic_visit(node)
-    
+
     def visit_Attribute(self, node):
         """
         Public method to record simplifiable names.
-        
+
         If 'import typing' or 'import typing as t' is used, add simplifiable
         names that were used later on in the code.
-        
+
         @param node reference to the AST Attribute node
         @type ast.Attribute
         """
         if (
-            node.attr in AnnotationsFutureVisitor.SimplifyableTypes and
-            isinstance(node.value, ast.Name) and
-            node.value.id in self.__typingAliases
+            node.attr in AnnotationsFutureVisitor.SimplifyableTypes
+            and isinstance(node.value, ast.Name)
+            and node.value.id in self.__typingAliases
         ):
             self.__typingImports.append(f"{node.value.id}.{node.attr}")
-        
+
         self.generic_visit(node)
-    
+
     def importsFutureAnnotations(self):
         """
         Public method to check, if the analyzed code uses future annotation.
-        
+
         @return flag indicatung the use of future annotation
         @rtype bool
         """
         return self.__importsFutureAnnotations
-    
+
     def hasTypingImports(self):
         """
         Public method to check, if the analyzed code includes typing imports.
-        
+
         @return flag indicating the use of typing imports
         @rtype bool
         """
         return bool(self.__typingImports)
-    
+
     def getTypingImports(self):
         """
         Public method to get the list of typing imports.
-        
+
         @return list of typing imports
         @rtype list of str
         """

eric ide

mercurial