Support `ctx: UnionType` annots for `@tractor.context` eps
							parent
							
								
									58a818472c
								
							
						
					
					
						commit
						6a94a520d6
					
				|  | @ -47,6 +47,9 @@ from functools import partial | ||||||
| import inspect | import inspect | ||||||
| from pprint import pformat | from pprint import pformat | ||||||
| import textwrap | import textwrap | ||||||
|  | from types import ( | ||||||
|  |     UnionType, | ||||||
|  | ) | ||||||
| from typing import ( | from typing import ( | ||||||
|     Any, |     Any, | ||||||
|     AsyncGenerator, |     AsyncGenerator, | ||||||
|  | @ -2548,7 +2551,14 @@ def context( | ||||||
|     name: str |     name: str | ||||||
|     param: Type |     param: Type | ||||||
|     for name, param in annots.items(): |     for name, param in annots.items(): | ||||||
|         if param is Context: |         if ( | ||||||
|  |             param is Context | ||||||
|  |             or ( | ||||||
|  |                 isinstance(param, UnionType) | ||||||
|  |                 and | ||||||
|  |                 Context in param.__args__ | ||||||
|  |             ) | ||||||
|  |         ): | ||||||
|             ctx_var_name: str = name |             ctx_var_name: str = name | ||||||
|             break |             break | ||||||
|     else: |     else: | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue