@@ -8642,24 +8642,25 @@ class Y(Generic[Tx]):
86428642
86438643 def test_invalid_special_forms (self ):
86448644 # tests _lax_type_check to raise errors the same way as the typing module.
8645+ # Regex capture "< class 'module.name'> and "module.name"
86458646 with self .assertRaisesRegex (
8646- TypeError , "Plain .*Protocol('>)? is not valid as type argument"
8647+ TypeError , r "Plain .*Protocol('>)? is not valid as type argument"
86478648 ):
86488649 evaluate_forward_ref (typing .ForwardRef ("Protocol" ), globals = vars (typing ))
86498650 with self .assertRaisesRegex (
8650- TypeError , "Plain .*Generic('>)? is not valid as type argument"
8651+ TypeError , r "Plain .*Generic('>)? is not valid as type argument"
86518652 ):
86528653 evaluate_forward_ref (typing .ForwardRef ("Generic" ), globals = vars (typing ))
8653- with self .assertRaisesRegex (TypeError , "Plain typing(_extensions)?.Final is not valid as type argument" ):
8654+ with self .assertRaisesRegex (TypeError , r "Plain typing(_extensions)?\ .Final is not valid as type argument" ):
86548655 evaluate_forward_ref (typing .ForwardRef ("Final" ), globals = vars (typing ))
8655- with self .assertRaisesRegex (TypeError , "Plain typing(_extensions)?.ClassVar is not valid as type argument" ):
8656+ with self .assertRaisesRegex (TypeError , r "Plain typing(_extensions)?\ .ClassVar is not valid as type argument" ):
86568657 evaluate_forward_ref (typing .ForwardRef ("ClassVar" ), globals = vars (typing ))
86578658 if _FORWARD_REF_HAS_CLASS :
86588659 self .assertIs (evaluate_forward_ref (typing .ForwardRef ("Final" , is_class = True ), globals = vars (typing )), Final )
86598660 self .assertIs (evaluate_forward_ref (typing .ForwardRef ("ClassVar" , is_class = True ), globals = vars (typing )), ClassVar )
8660- with self .assertRaisesRegex (TypeError , "Plain .*Final('>)? is not valid as type argument" ):
8661+ with self .assertRaisesRegex (TypeError , r "Plain typing(_extensions)?\.Final is not valid as type argument" ):
86618662 evaluate_forward_ref (typing .ForwardRef ("Final" , is_argument = False ), globals = vars (typing ))
8662- with self .assertRaisesRegex (TypeError , "Plain .*ClassVar('>)? is not valid as type argument" ):
8663+ with self .assertRaisesRegex (TypeError , r "Plain typing(_extensions)?\.ClassVar is not valid as type argument" ):
86638664 evaluate_forward_ref (typing .ForwardRef ("ClassVar" , is_argument = False ), globals = vars (typing ))
86648665 else :
86658666 self .assertIs (evaluate_forward_ref (typing .ForwardRef ("Final" , is_argument = False ), globals = vars (typing )), Final )
0 commit comments