plugin.core: Less introspective DIRECTIVE setting.
Python 3.6 does not implement __class_getitem__, and because of that it's not possible to introspect when things like Hook[Transaction] are called. Sidestep the issue with a more explicit assignment.
This commit is contained in:
		
							parent
							
								
									6f3e5eb905
								
							
						
					
					
						commit
						e1c507c025
					
				
					 1 changed files with 2 additions and 4 deletions
				
			
		| 
						 | 
					@ -69,12 +69,10 @@ class Hook(Generic[Entry], metaclass=abc.ABCMeta):
 | 
				
			||||||
    @abc.abstractmethod
 | 
					    @abc.abstractmethod
 | 
				
			||||||
    def run(self, entry: Entry) -> errormod.Iter: ...
 | 
					    def run(self, entry: Entry) -> errormod.Iter: ...
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def __init_subclass__(cls) -> None:
 | 
					 | 
				
			||||||
        # cls.__orig_bases__ comes from the ABCMeta metaclass
 | 
					 | 
				
			||||||
        cls.DIRECTIVE = cls.__orig_bases__[0].__args__[0]  # type:ignore[attr-defined]
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class TransactionHook(Hook[Transaction]):
 | 
				
			||||||
 | 
					    DIRECTIVE = Transaction
 | 
				
			||||||
 | 
					
 | 
				
			||||||
TransactionHook = Hook[Transaction]
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
### HELPER CLASSES
 | 
					### HELPER CLASSES
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue