1111from  abc  import  abstractmethod 
1212from  enum  import  Enum 
1313
14- 
1514from  paraview .util .vtkAlgorithm  import  (  # type: ignore[import-not-found] 
1615    VTKPythonAlgorithmBase , smdomain , smhint , smproperty , smproxy ,
1716)  # source: https://github.com/Kitware/ParaView/blob/master/Wrapping/Python/paraview/util/vtkAlgorithm.py 
1817
1918from  vtkmodules .vtkCommonDataModel  import  (
20-     vtkMultiBlockDataSet , )
19+     vtkMultiBlockDataSet ,
20+     vtkDataObject ,
21+ )
2122
2223from  vtkmodules .vtkCommonCore  import  (
2324    vtkInformation ,
@@ -43,6 +44,8 @@ class PVMyFilter:
4344        ... 
4445
4546""" 
47+ 
48+ 
4649# Enum for filter categories 
4750class  FilterCategory ( str , Enum  ):
4851    """String Enum to sort into category in PV task bar under Plugins.""" 
@@ -55,15 +58,17 @@ class FilterCategory( str, Enum ):
5558    # Add more as needed 
5659
5760
58- U  =  TypeVar ('U' )
61+ U  =  TypeVar ( 'U' , bound = 'vtkDataObject'  )
62+ 
63+ 
5964@runtime_checkable  
60- class  IsSISOFilter ( Protocol [U ] ):
65+ class  IsSISOFilter ( Protocol [  U   ] ):
6166    """Protocol to ensure that the wrapped filter defines the correct Filter core function.""" 
6267
6368    @abstractmethod  
6469    def  Filter (
6570        self ,
66-         inputMesh : U ,  
71+         inputMesh : U ,
6772        outputMesh : U ,
6873    ) ->  None :
6974        """Define filter here. 
@@ -75,12 +80,14 @@ def Filter(
7580        """ 
7681        raise  NotImplementedError 
7782
83+ 
7884T  =  TypeVar ( 'T' , bound = 'IsSISOFilter'  )
7985
8086
8187def  SISOFilter ( category : FilterCategory , decoratedLabel : str ,
82-                 decoratedType : Union [str ,list ] ) ->  Callable [ [ Type [ T  ] ], Type [ T  ] ]:
88+                 decoratedType : Union [  str ,  list   ] ) ->  Callable [ [ Type [ T  ] ], Type [ T  ] ]:
8389    """Decorate Single Input Single Output (SISO) filter.""" 
90+ 
8491    def  decoratedClass ( cls : Type [ T  ] ) ->  Type [ T  ]:
8592        """Outer wrapper function. All is in the WrappingClass below.""" 
8693        originalInit  =  cls .__init__ 
@@ -94,11 +101,12 @@ def __init__( self, *ar: Any, **kw: Any ) -> None:
94101                    ar : Fowarded arguments 
95102                    kw : Forwarded keywords args 
96103                """ 
97-                 VTKPythonAlgorithmBase .__init__ ( self ,
98-                                                  nInputPorts = 1 ,
99-                                                  nOutputPorts = 1 ,
100-                                                  inputType = decoratedType  if  isinstance (decoratedType ,str ) else  "vtkDataObject" ,
101-                                                  outputType = decoratedType  if  isinstance (decoratedType ,str ) else  "vtkDataObject" )
104+                 VTKPythonAlgorithmBase .__init__ (
105+                     self ,
106+                     nInputPorts = 1 ,
107+                     nOutputPorts = 1 ,
108+                     inputType = decoratedType  if  isinstance ( decoratedType , str  ) else  "vtkDataObject" ,
109+                     outputType = decoratedType  if  isinstance ( decoratedType , str  ) else  "vtkDataObject"  )
102110
103111                #If wrapped class has more to init there it is applied 
104112                #avoid the overwritten init by decorator taking place of the cls 
@@ -155,16 +163,16 @@ def RequestData(
155163
156164                cls .Filter ( self , inputMesh , outputMesh  )
157165                return  1 
158-          
166+ 
159167        # Copy all methods and attributes from cls, including decorator metadata 
160-         for  attrName  in  dir (cls ):
161-             if  attrName .startswith ('_' ):
168+         for  attrName  in  dir (  cls   ):
169+             if  attrName .startswith (  '_'   ):
162170                continue   # Skip private/magic methods (already handled or inherited) 
163-              
164-             attr  =  getattr (cls , attrName )
171+ 
172+             attr  =  getattr (  cls , attrName   )
165173            # Copy methods with their decorators 
166-             if  callable (attr ) and  attrName  not  in WrappingClass .__dict__ :
167-                 setattr (WrappingClass ,attrName ,attr )
174+             if  callable (  attr   ) and  attrName  not  in WrappingClass .__dict__ :
175+                 setattr (  WrappingClass ,  attrName ,  attr   )
168176
169177        # Copy metadata 
170178        WrappingClass .__name__  =  cls .__name__ 
@@ -175,7 +183,7 @@ def RequestData(
175183
176184        #decorate it old fashion way 
177185        WrappingClass  =  smdomain .datatype (
178-             dataTypes = [ decoratedType  ] if  isinstance (decoratedType ,str ) else  decoratedType ,
186+             dataTypes = [ decoratedType  ] if  isinstance (  decoratedType ,  str   ) else  decoratedType ,
179187            composite_data_supported = True ,
180188        )( WrappingClass  )
181189        WrappingClass  =  smproperty .input ( name = "Input" , port_index = 0  )( WrappingClass  )
0 commit comments