mirror of
				https://github.com/python/cpython.git
				synced 2025-10-30 21:21:22 +00:00 
			
		
		
		
	bpo-42233: Correctly repr GenericAlias when used with typing module (GH-23081)
Noticed by @serhiy-storchaka in the bpo.  `typing`'s types were not showing the parameterized generic.
Eg. previously:
```python
>>> typing.Union[dict[str, float], list[int]]
'typing.Union[dict, list]'
```
Now:
```python
>>> typing.Union[dict[str, float], list[int]]
'typing.Union[dict[str, float], list[int]]'
```
Automerge-Triggered-By: GH:gvanrossum
(cherry picked from commit 1f7dfb277e)
Co-authored-by: kj <28750310+Fidget-Spinner@users.noreply.github.com>
			
			
This commit is contained in:
		
							parent
							
								
									4c239a3222
								
							
						
					
					
						commit
						e81e09bfc8
					
				
					 3 changed files with 12 additions and 0 deletions
				
			
		|  | @ -300,6 +300,8 @@ def test_repr(self): | |||
|         self.assertEqual(repr(u), repr(int)) | ||||
|         u = Union[List[int], int] | ||||
|         self.assertEqual(repr(u), 'typing.Union[typing.List[int], int]') | ||||
|         u = Union[list[int], dict[str, float]] | ||||
|         self.assertEqual(repr(u), 'typing.Union[list[int], dict[str, float]]') | ||||
| 
 | ||||
|     def test_cannot_subclass(self): | ||||
|         with self.assertRaises(TypeError): | ||||
|  | @ -411,6 +413,7 @@ def test_repr(self): | |||
|         self.assertEqual(repr(Tuple[()]), 'typing.Tuple[()]') | ||||
|         self.assertEqual(repr(Tuple[int, float]), 'typing.Tuple[int, float]') | ||||
|         self.assertEqual(repr(Tuple[int, ...]), 'typing.Tuple[int, ...]') | ||||
|         self.assertEqual(repr(Tuple[list[int]]), 'typing.Tuple[list[int]]') | ||||
| 
 | ||||
|     def test_errors(self): | ||||
|         with self.assertRaises(TypeError): | ||||
|  | @ -483,6 +486,8 @@ def test_repr(self): | |||
|         self.assertEqual(repr(ct2), 'typing.Callable[[str, float], int]') | ||||
|         ctv = Callable[..., str] | ||||
|         self.assertEqual(repr(ctv), 'typing.Callable[..., str]') | ||||
|         ct3 = Callable[[str, float], list[int]] | ||||
|         self.assertEqual(repr(ct3), 'typing.Callable[[str, float], list[int]]') | ||||
| 
 | ||||
|     def test_callable_with_ellipsis(self): | ||||
| 
 | ||||
|  | @ -2273,6 +2278,8 @@ def test_repr(self): | |||
|         self.assertEqual(repr(cv), 'typing.Final[int]') | ||||
|         cv = Final[Employee] | ||||
|         self.assertEqual(repr(cv), 'typing.Final[%s.Employee]' % __name__) | ||||
|         cv = Final[tuple[int]] | ||||
|         self.assertEqual(repr(cv), 'typing.Final[tuple[int]]') | ||||
| 
 | ||||
|     def test_cannot_subclass(self): | ||||
|         with self.assertRaises(TypeError): | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Miss Islington (bot)
						Miss Islington (bot)