Skip to content

More documentation updates - #5053

Merged
JukkaL merged 5 commits into
masterfrom
doc-updates-2
May 31, 2018
Merged

JukkaL merged 5 commits into
masterfrom
doc-updates-2

Conversation

@JukkaL

@JukkaL JukkaL commented May 15, 2018

Copy link
Copy Markdown
Collaborator

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.

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.
Comment thread docs/source/additional_features.rst Outdated
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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"the" is duplicated

Comment thread docs/source/additional_features.rst Outdated

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread docs/source/additional_features.rst Outdated
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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are -> and

Comment thread docs/source/additional_features.rst Outdated
***********************

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where -> When

.. code-block:: python

class A:
x = None # type: List[int] # Declare attribute 'x' of type List[int]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread docs/source/protocols.rst
def __iter__(self) -> Iterator[T]

``Iterator[T]``
---------------

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a syntax error here? GitHub highlights it.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread docs/source/protocols.rst Outdated

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made the comment more explicit (ha).

Comment thread docs/source/protocols.rst Outdated

close_all([Resource(), open('some/file')]) # Okay!

``Resource`` is a subtype of the ``SupportClose`` protocol since it defines

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SupportsClose, not SupportClose

Comment thread docs/source/protocols.rst Outdated

.. code-block:: python

class NewProtocol(SupportsClose): # This is NOT a protocol

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make this clearer, maybe name this class NotAProtocol.

Comment thread docs/source/protocols.rst Outdated
self.left: Optional['SimpleTree'] = None
self.right: Optional['SimpleTree'] = None

root = SimpleTree(0) # type: TreeLike # OK

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use variable annotation here.

@emmatyping

Copy link
Copy Markdown
Member

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

@JukkaL

JukkaL commented May 29, 2018

Copy link
Copy Markdown
Collaborator Author

This is ready for another round of review.

@gvanrossum gvanrossum left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread docs/source/protocols.rst
def __iter__(self) -> Iterator[T]

``Iterator[T]``
---------------

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@emmatyping emmatyping left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@JukkaL
JukkaL merged commit f95e584 into master May 31, 2018
@msullivan
msullivan deleted the doc-updates-2 branch May 31, 2018 19:02
msullivan pushed a commit that referenced this pull request May 31, 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.

* 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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants