11"""Common test fixtures."""
22from functools import lru_cache
3- from typing import Any
3+ from typing import Any , Generic , TypeVar
44
55
66class SomeClass :
77 """Testing class."""
88
99 def foo (self , val : str ) -> str :
1010 """Get the foo string."""
11- ...
1211
1312 def bar (self , a : int , b : float , c : str ) -> bool :
1413 """Get the bar bool based on a few inputs."""
15- ...
1614
1715 @staticmethod
1816 def fizzbuzz (hello : str ) -> int :
1917 """Fizz some buzzes."""
20- ...
2118
2219 def do_the_thing (self , * , flag : bool ) -> None :
2320 """Perform a side-effect without a return value."""
24- ...
2521
2622 @property
2723 def primitive_property (self ) -> str :
2824 """Get a primitive computed property."""
29- ...
3025
3126 @lru_cache (maxsize = None )
3227 def some_wrapped_method (self , val : str ) -> str :
3328 """Get a thing through a wrapped method."""
34- ...
3529
3630
3731class SomeNestedClass :
@@ -41,62 +35,65 @@ class SomeNestedClass:
4135
4236 def foo (self , val : str ) -> str :
4337 """Get the foo string."""
44- ...
4538
4639 @property
4740 def child (self ) -> SomeClass :
4841 """Get the child instance."""
49- ...
5042
5143
5244class SomeAsyncClass :
5345 """Async testing class."""
5446
5547 async def foo (self , val : str ) -> str :
5648 """Get the foo string."""
57- ...
5849
5950 async def bar (self , a : int , b : float , c : str ) -> bool :
6051 """Get the bar bool based on a few inputs."""
61- ...
6252
6353 async def do_the_thing (self , * , flag : bool ) -> None :
6454 """Perform a side-effect without a return value."""
65- ...
6655
6756
6857class SomeAsyncCallableClass :
6958 """Async callable class."""
7059
7160 async def __call__ (self , val : int ) -> int :
7261 """Get an integer."""
73- ...
7462
7563
7664class SomeCallableClass :
7765 """Async callable class."""
7866
7967 async def __call__ (self , val : int ) -> int :
8068 """Get an integer."""
81- ...
8269
8370
8471def noop (* args : Any , ** kwargs : Any ) -> Any :
8572 """No-op."""
86- ...
8773
8874
8975def some_func (val : str ) -> str :
9076 """Test function."""
91- ...
9277
9378
9479async def some_async_func (val : str ) -> str :
9580 """Async test function."""
96- ...
9781
9882
9983@lru_cache (maxsize = None )
10084def some_wrapped_func (val : str ) -> str :
10185 """Wrapped test function."""
102- ...
86+
87+
88+ GenericT = TypeVar ("GenericT" )
89+
90+
91+ class GenericClass (Generic [GenericT ]):
92+ """A generic class definition."""
93+
94+ def hello (self , val : GenericT ) -> None :
95+ """Say hello."""
96+
97+
98+ ConcreteAlias = GenericClass [str ]
99+ """An alias with a generic type specified"""
0 commit comments