mirror of
				https://github.com/python/cpython.git
				synced 2025-11-03 23:21:29 +00:00 
			
		
		
		
	gh-126705: Make os.PathLike more like a protocol (#126706)
it can now be used as a base class in other protocols
This commit is contained in:
		
							parent
							
								
									73cf069099
								
							
						
					
					
						commit
						a83472f49b
					
				
					 3 changed files with 6 additions and 0 deletions
				
			
		| 
						 | 
					@ -8,6 +8,7 @@
 | 
				
			||||||
import inspect
 | 
					import inspect
 | 
				
			||||||
import itertools
 | 
					import itertools
 | 
				
			||||||
import operator
 | 
					import operator
 | 
				
			||||||
 | 
					import os
 | 
				
			||||||
import pickle
 | 
					import pickle
 | 
				
			||||||
import re
 | 
					import re
 | 
				
			||||||
import sys
 | 
					import sys
 | 
				
			||||||
| 
						 | 
					@ -4252,6 +4253,9 @@ def test_builtin_protocol_allowlist(self):
 | 
				
			||||||
            class CustomProtocol(TestCase, Protocol):
 | 
					            class CustomProtocol(TestCase, Protocol):
 | 
				
			||||||
                pass
 | 
					                pass
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        class CustomPathLikeProtocol(os.PathLike, Protocol):
 | 
				
			||||||
 | 
					            pass
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        class CustomContextManager(typing.ContextManager, Protocol):
 | 
					        class CustomContextManager(typing.ContextManager, Protocol):
 | 
				
			||||||
            pass
 | 
					            pass
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1944,6 +1944,7 @@ def _allow_reckless_class_checks(depth=2):
 | 
				
			||||||
        'Reversible', 'Buffer',
 | 
					        'Reversible', 'Buffer',
 | 
				
			||||||
    ],
 | 
					    ],
 | 
				
			||||||
    'contextlib': ['AbstractContextManager', 'AbstractAsyncContextManager'],
 | 
					    'contextlib': ['AbstractContextManager', 'AbstractAsyncContextManager'],
 | 
				
			||||||
 | 
					    'os': ['PathLike'],
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1 @@
 | 
				
			||||||
 | 
					Allow :class:`os.PathLike` to be a base for Protocols.
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue