Skip to content

Commit

Permalink
Fix trailing spaces (#1537)
Browse files Browse the repository at this point in the history
  • Loading branch information
JelleZijlstra authored Dec 11, 2023
1 parent 7117775 commit 9f35263
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 24 deletions.
2 changes: 1 addition & 1 deletion docs/spec/annotations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ have a return annotation; the default behavior is thus the same as for
other methods.)

A type checker is expected to check the body of a checked function for
consistency with the given annotations. The annotations may also be
consistency with the given annotations. The annotations may also be
used to check correctness of calls appearing in other checked functions.

Type checkers are expected to attempt to infer as much information as
Expand Down
22 changes: 11 additions & 11 deletions docs/spec/callables.rst
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ compatible::

class Animal(TypedDict):
name: str

class Dog(Animal):
breed: str

Expand All @@ -181,10 +181,10 @@ function arguments. Again, the rest of the parameters have to be compatible.
Continuing the previous example::

class Example(TypedDict):
animal: Animal
animal: Animal
string: str
number: NotRequired[int]

def src(**kwargs: Unpack[Example]): ...
def dest(*, animal: Dog, string: str, number: int = ...): ...

Expand Down Expand Up @@ -245,7 +245,7 @@ type ``T``::

class Vehicle:
...

class Car(Vehicle):
...

Expand All @@ -255,7 +255,7 @@ type ``T``::
class Vehicles(TypedDict):
car: Car
moto: Motorcycle

def dest(**kwargs: Unpack[Vehicles]): ...
def src(**kwargs: Vehicle): ...

Expand All @@ -279,7 +279,7 @@ consider the following example::

class Animal(TypedDict):
name: str

class Dog(Animal):
breed: str

Expand All @@ -290,21 +290,21 @@ consider the following example::

def foo(**kwargs: Unpack[Animal]):
print(kwargs["name"].capitalize())

def bar(**kwargs: Unpack[Animal]):
takes_name(**kwargs)

def baz(animal: Animal):
takes_name(**animal)

def spam(**kwargs: Unpack[Animal]):
baz(kwargs)

foo(**animal) # OK! foo only expects and uses keywords of 'Animal'.

bar(**animal) # WRONG! This will fail at runtime because 'breed' keyword
# will be passed to 'takes_name' as well.

spam(**animal) # WRONG! Again, 'breed' keyword will be eventually passed
# to 'takes_name'.

Expand Down
6 changes: 3 additions & 3 deletions docs/spec/generics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1050,7 +1050,7 @@ Or when using the built-in syntax for generics in Python 3.12 and higher::

class Array[*Ts]:
...

def foo[*Ts](*args: *Ts):
...

Expand Down Expand Up @@ -1685,7 +1685,7 @@ to the ``TypeVarTuple``:

Ptang[str, bool, float] # T1=str, T3=float, T2=bool, Ts=tuple[()]
Ptang[str, bool, float, int] # T1=str, T3=int, T2=float, Ts=tuple[bool]

Note that the minimum number of type arguments in such cases is set by
the number of ``TypeVar``\s:

Expand Down Expand Up @@ -2406,7 +2406,7 @@ Here is an example.
class ClassA[T1, T2, T3](list[T1]):
def method1(self, a: T2) -> None:
...

def method2(self) -> T3:
...

Expand Down
2 changes: 1 addition & 1 deletion docs/spec/historical.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ complex cases, a comment of the following format may be used::
x = [1, 2] # type: list[int]

Type comments should be put on the last line of the statement that
contains the variable definition.
contains the variable definition.

These should be treated as equivalent to annotating the variables
using :pep:`526` variable annotations::
Expand Down
4 changes: 2 additions & 2 deletions docs/spec/literal.rst
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ allowing them in the future.
- Floats: e.g. ``Literal[3.14]``. Representing Literals of infinity or NaN
in a clean way is tricky; real-world APIs are unlikely to vary their
behavior based on a float parameter.

- Any: e.g. ``Literal[Any]``. ``Any`` is a type, and ``Literal[...]`` is
meant to contain values only. It is also unclear what ``Literal[Any]``
would actually semantically mean.
Expand Down Expand Up @@ -515,7 +515,7 @@ involving Literal bools. For example, we can combine ``Literal[True]``,
scalar += 3 # Type checks: type of 'scalar' is narrowed to 'int'
else:
scalar += "foo" # Type checks: type of 'scalar' is narrowed to 'str'

Interactions with Final
"""""""""""""""""""""""

Expand Down
8 changes: 4 additions & 4 deletions docs/spec/narrowing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ allows for cases like the example above where ``list[str]`` is not assignable
to ``list[object]``.

When a conditional statement includes a call to a user-defined type guard
function, and that function returns true, the expression passed as the first
positional argument to the type guard function should be assumed by a static
type checker to take on the type specified in the TypeGuard return type,
function, and that function returns true, the expression passed as the first
positional argument to the type guard function should be assumed by a static
type checker to take on the type specified in the TypeGuard return type,
unless and until it is further narrowed within the conditional code block.

Some built-in type guards provide narrowing for both positive and negative
Expand All @@ -97,7 +97,7 @@ is not narrowed in the negative case.
else:
reveal_type(val) # OneOrTwoStrs
...

if not is_two_element_tuple(val):
reveal_type(val) # OneOrTwoStrs
...
Expand Down
2 changes: 0 additions & 2 deletions docs/spec/requirements.txt

This file was deleted.

0 comments on commit 9f35263

Please sign in to comment.