Skip to content

More improvements to cheat sheet #1659

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

Merged
merged 2 commits into from
Jun 6, 2016
Merged

Conversation

gnprice
Copy link
Collaborator

@gnprice gnprice commented Jun 6, 2016

I made a revision pass through the whole document, and made several
kinds of changes:

  • Organize it all in hopes of making things easier to find with
    thematic groupings, headers, spacing, and putting the key words at
    the start of each description.
  • Give the descriptions more of a common style.
  • Explain a few things like reveal_type and Sequence a little more
    fully.
  • Cut the redundant Tuple example.
  • Add descriptions for the class-definition example.
  • Add a description for the generator-function example, and change its
    return-type annotation from Iterator to Iterable. That gets us
    out of trying to explain the difference between those, as Iterable
    is the one we mention elsewhere for function parameters. And as far
    as I can see, there isn't a reason we need to recommend Iterator
    instead here.

I'd have liked also to switch from recommending six.text_type to
typing.Text, but that should wait until 3.5.2, with Text, is out.

/cc @timabbott -- re-revisions welcome!

# Mapping is an abtract base class for a dict-type thing that may
# not support writing to the mapping
# A generator function that yields ints is secretly just a function that
# returns an iterable (see below) of ints, so that's how we annotate it.
Copy link
Member

Choose a reason for hiding this comment

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

Technically it's an Iterator. Not sure if this distinction matters, given that Iterator inherits from Iterable.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah. I wrote Iterator first for that reason, then contemplated explaining the distinction between Iterator and Iterable (having already recommended Iterable elsewhere), and concluded there isn't a good explanation in this context because the distinction doesn't actually matter.

@gvanrossum
Copy link
Member

Also, we really need to have a PY3 version of this...

@gvanrossum
Copy link
Member

gvanrossum commented Jun 6, 2016

Also looks like AppVeyor found something questionable about typed_ast. @ddfisher any idea? I think I'll just rename appveyor.yml until we have fixed this. (Done: fd782b7.)

@@ -1,7 +1,7 @@
Mypy syntax cheat sheet (Python 2)
==================================

This document is a quick cheat sheet showing how the PEP-484 type
This document is a quick cheat sheet showing how the PEP 484 type

Choose a reason for hiding this comment

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

Make PEP 484 a link

@ddfisher
Copy link
Collaborator

ddfisher commented Jun 6, 2016

We now install typed_ast from PyPI as part of CI so we can run fast parser tests... and it doesn't build on Windows yet. :(



Standard duck types / ABCs
**************************

Choose a reason for hiding this comment

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

you probably want to expand what those titles mean. Most people writing Python code don't know those terms.

Choose a reason for hiding this comment

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

(Maybe with a link)

@gnprice
Copy link
Collaborator Author

gnprice commented Jun 6, 2016

Thanks for all the review! Pushed a new version.

The comments that pointed out additional things we should cover, I added if they seemed pretty tricky to explain and otherwise I added as TODO items or will make issues for -- I want to start populating a "for newcomers" label on issues, composed mainly of easy fixes to documentation and the like. Lasse showed me how coala does this (see the issues at http://tinyurl.com/coala-new), and they've made very good use of it.

gnprice and others added 2 commits June 6, 2016 12:59
I made a revision pass through the whole document, and made several
kinds of changes:

* Organize it all in hopes of making things easier to find with
  thematic groupings, headers, spacing, and putting the key words at
  the start of each description.

* Give the descriptions more of a common style.

* Explain a few things like `reveal_type` and `Sequence` a little more
  fully.

* Cut the redundant `Tuple` example.

* Add descriptions for the class-definition example.

* Add a description for the generator-function example, and change its
  return-type annotation from `Iterator` to `Iterable`.  That gets us
  out of trying to explain the difference between those, as `Iterable`
  is the one we mention elsewhere for function parameters.  And as far
  as I can see, there isn't a reason we need to recommend `Iterator`
  instead here.

I'd have liked also to switch from recommending `six.text_type` to
`typing.Text`, but that should wait until 3.5.2, with `Text`, is out.
@gnprice
Copy link
Collaborator Author

gnprice commented Jun 6, 2016

(Rebased to pick up Guido's disabling of AppVeyor.)

@gvanrossum gvanrossum merged commit c8b3916 into python:master Jun 6, 2016
@gvanrossum
Copy link
Member

Somehow the appveyor.yml file still wreaked havoc; I've ignored it.

@gnprice gnprice deleted the cheat-sheet branch June 7, 2016 00:35
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