New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More documentation updates #5053

Merged
merged 5 commits into from May 31, 2018

Conversation

Projects
None yet
4 participants
@JukkaL
Collaborator

JukkaL commented May 15, 2018

Partial list of changes:

  • Move a bunch of less core functionality to later in the documentation to
    make it easier to get started with mypy.

  • Remove some obsolete things.

  • Migrate more examples to use variable annotations.

  • Clarify various explanations.

More documentation updates
Partial list of changes:

* Move a bunch of less core functionality to later in the documentation to
  make it easier to get started with mypy.

* Remove some obsolete things.

* Migrate more examples to use variable annotations.

* Clarify various explanations.
first overloaded definition, and ignores the type annotations on the
implementation of ``__getitem__``. The code in the body of the
definition of ``__getitem__`` is checked against the annotations on
the the corresponding declaration. In this case the body is checked

This comment has been minimized.

@JelleZijlstra

JelleZijlstra May 15, 2018

Collaborator

"the" is duplicated

The annotations on the function body must be compatible with the
types given for the overloaded variants listed above it. The type
checker will verify that all the types listed the overloaded variants

This comment has been minimized.

@JelleZijlstra

JelleZijlstra May 15, 2018

Collaborator

missing a preposition between "listed" and "the" (probably "for")

case it checks that the parameter type ``int`` and the return type
``T`` are compatible with ``Union[int, slice]`` and
``Union[T, Sequence[T]]`` for the first variant. For the second
variant it verifies that the parameter type ``slice`` are the return

This comment has been minimized.

@JelleZijlstra

JelleZijlstra May 15, 2018

Collaborator

are -> and

***********************
As an experimental mypy extension, you can specify ``Callable`` types
that support keyword arguments, optional arguments, and more. Where

This comment has been minimized.

@JelleZijlstra

JelleZijlstra May 15, 2018

Collaborator

Where -> When

.. code-block:: python
class A:
x = None # type: List[int] # Declare attribute 'x' of type List[int]

This comment has been minimized.

@JelleZijlstra

JelleZijlstra May 15, 2018

Collaborator

Should we mention the special case where this allows None even if strict optional is on?

This comment has been minimized.

@JukkaL

JukkaL May 29, 2018

Collaborator

Good idea, added a short discussion of the special case.

def __iter__(self) -> Iterator[T]
``Iterator[T]``
---------------

This comment has been minimized.

@JelleZijlstra

JelleZijlstra May 15, 2018

Collaborator

Is there a syntax error here? GitHub highlights it.

This comment has been minimized.

@JukkaL

JukkaL May 29, 2018

Collaborator

It seems to work fine. Could be a problem with the syntax highlighter that GitHub uses.

This comment has been minimized.

@gvanrossum

gvanrossum May 30, 2018

Member

Maybe because there's no colon or body on the def in the preceding code block?

class SupportsClose(Protocol):
def close(self) -> None:
... # Explicit '...'

This comment has been minimized.

@JelleZijlstra

JelleZijlstra May 15, 2018

Collaborator

I'm not sure why this is "Explicit" or why this is significant.

This comment has been minimized.

@JukkaL

JukkaL May 29, 2018

Collaborator

Made the comment more explicit (ha).

close_all([Resource(), open('some/file')]) # Okay!
``Resource`` is a subtype of the ``SupportClose`` protocol since it defines

This comment has been minimized.

@JelleZijlstra

JelleZijlstra May 15, 2018

Collaborator

SupportsClose, not SupportClose

.. code-block:: python
class NewProtocol(SupportsClose): # This is NOT a protocol

This comment has been minimized.

@JelleZijlstra

JelleZijlstra May 15, 2018

Collaborator

To make this clearer, maybe name this class NotAProtocol.

self.left: Optional['SimpleTree'] = None
self.right: Optional['SimpleTree'] = None
root = SimpleTree(0) # type: TreeLike # OK

This comment has been minimized.

@JelleZijlstra

JelleZijlstra May 15, 2018

Collaborator

Use variable annotation here.

@ethanhs

This comment has been minimized.

Collaborator

ethanhs commented May 24, 2018

This should be rebased on top of the new re-write.

@JukkaL

This comment has been minimized.

Collaborator

JukkaL commented May 29, 2018

This is ready for another round of review.

@gvanrossum

This is way too much to review, I propose to just land it.

def __iter__(self) -> Iterator[T]
``Iterator[T]``
---------------

This comment has been minimized.

@gvanrossum

gvanrossum May 30, 2018

Member

Maybe because there's no colon or body on the def in the preceding code block?

@ethanhs

I went ahead and skimmed it, didn't see any other obvious issues beyond the note by @gvanrossum.

@msullivan msullivan referenced this pull request May 31, 2018

Closed

Release 0.610 planning #5096

@JukkaL JukkaL merged commit f95e584 into master May 31, 2018

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details

@msullivan msullivan deleted the doc-updates-2 branch May 31, 2018

msullivan added a commit that referenced this pull request May 31, 2018

More documentation updates (#5053)
Partial list of changes:

* Move a bunch of less core functionality to later in the documentation to
  make it easier to get started with mypy.

* Remove some obsolete things.

* Migrate more examples to use variable annotations.

* Clarify various explanations.

* Address feedback

* Move a few sections around in the table of contents

Also update some section titles.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment