Minor corrections in PEP 362, sent by Yury Selivanov.

This commit is contained in:
Andrew Svetlov 2012-08-13 21:31:39 +03:00
parent 32f1e342b4
commit 151209a801
1 changed files with 6 additions and 11 deletions

View File

@ -176,7 +176,7 @@ A Parameter object has the following public attributes and methods:
* ``Parameter.VAR_KEYWORD`` - a dict of keyword arguments * ``Parameter.VAR_KEYWORD`` - a dict of keyword arguments
that aren't bound to any other parameter. This corresponds that aren't bound to any other parameter. This corresponds
to a "\*\*kwds" parameter in a Python function definition. to a "\*\*kwargs" parameter in a Python function definition.
Always use ``Parameter.*`` constants for setting and checking Always use ``Parameter.*`` constants for setting and checking
value of the ``kind`` attribute. value of the ``kind`` attribute.
@ -391,9 +391,9 @@ Let's define some classes and functions:
def decorator(f): def decorator(f):
@wraps(f) @wraps(f)
def wrapper(*args, **kwds): def wrapper(*args, **kwargs):
full_args = shared_args + args full_args = shared_args + args
return f(*full_args, **kwds) return f(*full_args, **kwargs)
# Override signature # Override signature
sig = signature(f) sig = signature(f)
@ -488,14 +488,9 @@ Annotation Checker
# If the argument has a type specified, let's check that its # If the argument has a type specified, let's check that its
# default value (if present) conforms with the type. # default value (if present) conforms with the type.
try: if param.default is not param.empty and not isinstance(param.default, type_):
default = param.default raise ValueError("{func}: wrong type of a default value for {arg!r}". \
except AttributeError: format(func=func.__qualname__, arg=param.name))
continue
else:
if not isinstance(default, type_):
raise ValueError("{func}: wrong type of a default value for {arg!r}". \
format(func=func.__qualname__, arg=param.name))
def check_type(sig, arg_name, arg_type, arg_value): def check_type(sig, arg_name, arg_type, arg_value):
# Internal function that encapsulates arguments type checking # Internal function that encapsulates arguments type checking