File tree Expand file tree Collapse file tree 4 files changed +8
-21
lines changed
Expand file tree Collapse file tree 4 files changed +8
-21
lines changed Original file line number Diff line number Diff line change @@ -192,7 +192,10 @@ Classes
192192 the global and local namespaces in which the name is evaluated.
193193 *type_params *, if given, must be a tuple of
194194 :ref: `type parameters <type-params >` that are in scope while the forward
195- reference is being evaluated. *owner * is the object that owns the
195+ reference is being evaluated. This parameter should be provided (though it
196+ may be an empty tuple) if the *owner * parameter is not given and the
197+ :class: `~ForwardRef ` instance does not have an owner set.
198+ *owner * is the object that owns the
196199 annotation from which the forward reference derives, usually a function,
197200 class, or module.
198201
Original file line number Diff line number Diff line change @@ -3439,7 +3439,7 @@ Introspection helpers
34393439 the global and local namespaces.
34403440 *type_params * is a tuple of :ref: `type parameters <type-params >` that
34413441 are in scope when evaluating the forward reference.
3442- This parameter must be provided (though it may be an empty tuple) if *owner *
3442+ This parameter should be provided (though it may be an empty tuple) if *owner *
34433443 is not given and the forward reference does not already have an owner set.
34443444 *format * specifies the format of the annotation and is a member of
34453445 the :class: `annotationlib.Format ` enum.
Original file line number Diff line number Diff line change @@ -7284,20 +7284,7 @@ def test_evaluate_forward_ref(self):
72847284
72857285 def test_evaluate_forward_ref_no_type_params (self ):
72867286 ref = ForwardRef ('int' )
7287- with self .assertWarnsRegex (
7288- DeprecationWarning ,
7289- (
7290- "Failing to pass a value to the 'type_params' parameter "
7291- "of 'typing.evaluate_forward_ref' is deprecated, "
7292- "as it leads to incorrect behaviour"
7293- ),
7294- ):
7295- typing .evaluate_forward_ref (ref )
7296-
7297- # No warnings when `type_params` is passed:
7298- with warnings .catch_warnings (record = True ) as w :
7299- typing .evaluate_forward_ref (ref , type_params = ())
7300- self .assertEqual (w , [])
7287+ self .assertIs (typing .evaluate_forward_ref (ref ), int )
73017288
73027289
73037290class CollectionsAbcTests (BaseTestCase ):
Original file line number Diff line number Diff line change @@ -1024,7 +1024,7 @@ def evaluate_forward_ref(
10241024 owner = None ,
10251025 globals = None ,
10261026 locals = None ,
1027- type_params = _sentinel ,
1027+ type_params = None ,
10281028 format = annotationlib .Format .VALUE ,
10291029 _recursive_guard = frozenset (),
10301030):
@@ -1044,15 +1044,12 @@ def evaluate_forward_ref(
10441044 infer the namespaces to use for looking up names. *globals* and *locals*
10451045 can also be explicitly given to provide the global and local namespaces.
10461046 *type_params* is a tuple of type parameters that are in scope when
1047- evaluating the forward reference. This parameter must be provided (though
1047+ evaluating the forward reference. This parameter should be provided (though
10481048 it may be an empty tuple) if *owner* is not given and the forward reference
10491049 does not already have an owner set. *format* specifies the format of the
10501050 annotation and is a member of the annotationlib.Format enum.
10511051
10521052 """
1053- if type_params is _sentinel :
1054- _deprecation_warning_for_no_type_params_passed ("typing.evaluate_forward_ref" )
1055- type_params = ()
10561053 if format == annotationlib .Format .STRING :
10571054 return forward_ref .__forward_arg__
10581055 if forward_ref .__forward_arg__ in _recursive_guard :
You can’t perform that action at this time.
0 commit comments