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

Tag Anys with their provenance #3786

Merged
merged 29 commits into from Aug 4, 2017

Conversation

Projects
None yet
3 participants
@ilinum
Collaborator

ilinum commented Aug 1, 2017

This PR tags each instance of AnyType with where it comes from.
Each Any can be one (and only one) of the following:

  • implicit (if this Any type was inferred without a type annotation)
  • explicit (if this Any comes from an explicit Any in a type annotation)
  • from_unimported_type (if this Any comes from an unfollowed import)
  • from_omitted_generics (if this Any comes from an ommitted generic suchs as Any in List)
  • from_error (if this Any comes from an error)
  • special_form (if this Any is created for internal mypy purposes)

Plus, this PR contains an addition to AnyExpressionsReport to report most common "tags" of Anys (implicit, explicit, from_unimported_type, etc).

Note that I was not able to identify some of the Anys, specifically, Anys related to generators. I added a todo to each one with the following exact words(# todo: is type of this Any correct?). All of these should probably be resolved until this PR is ready to be merged.

Also, perhaps, it would be better to split the PR into two? (one would tag Anys with their provenance and the other PR would add the new kind of Any Exprs Report)

@ddfisher

At a high level, I think this is a good approach. See comments for some initial feedback.

Show outdated Hide outdated mypy/report.py
Show outdated Hide outdated mypy/report.py
Show outdated Hide outdated mypy/report.py
Show outdated Hide outdated mypy/report.py
Show outdated Hide outdated mypy/checker.py
Show outdated Hide outdated mypy/checker.py
Show outdated Hide outdated mypy/checker.py
Show outdated Hide outdated mypy/subtypes.py
@ilinum

This comment has been minimized.

Show comment
Hide comment
@ilinum

ilinum Aug 3, 2017

Collaborator

All right, all code review feedback should be addressed now!

Collaborator

ilinum commented Aug 3, 2017

All right, all code review feedback should be addressed now!

@ilinum ilinum changed the title from [WIP] Tag Anys with their provenance to Tag Anys with their provenance Aug 3, 2017

Show outdated Hide outdated mypy/semanal.py
fdef.arg_kinds,
[None if argument_elide_name(n) else n for n in fdef.arg_names],
ret_type or AnyType(),
ret_type or AnyType(TypeOfAny.implicit),

This comment has been minimized.

@ddfisher

ddfisher Aug 3, 2017

Collaborator

I think this (and the other Any in this function) should be special form.

@ddfisher

ddfisher Aug 3, 2017

Collaborator

I think this (and the other Any in this function) should be special form.

This comment has been minimized.

@ilinum

ilinum Aug 4, 2017

Collaborator

Done!

@ilinum

ilinum Aug 4, 2017

Collaborator

Done!

This comment has been minimized.

@ilinum

ilinum Aug 4, 2017

Collaborator

Okay, after making this change, tests were failing, so I made them implicit again.

@ilinum

ilinum Aug 4, 2017

Collaborator

Okay, after making this change, tests were failing, so I made them implicit again.

@@ -1191,7 +1194,7 @@ def named_type(self, qualified_name: str, args: List[Type] = None) -> Instance:
if args:
# TODO: assert len(args) == len(node.defn.type_vars)
return Instance(node, args)
return Instance(node, [AnyType()] * len(node.defn.type_vars))
return Instance(node, [AnyType(TypeOfAny.implicit)] * len(node.defn.type_vars))

This comment has been minimized.

@ddfisher

ddfisher Aug 3, 2017

Collaborator

I thiiiink this should be special form.

@ddfisher

ddfisher Aug 3, 2017

Collaborator

I thiiiink this should be special form.

This comment has been minimized.

@ilinum

ilinum Aug 4, 2017

Collaborator

Done!

@ilinum

ilinum Aug 4, 2017

Collaborator

Done!

ilinum added some commits Aug 4, 2017

@ddfisher

Let's do this.

ilinum added some commits Aug 4, 2017

Use actual class instead of NewType
(NewType is not supported in python 3.5.1)
@ddfisher

This comment has been minimized.

Show comment
Hide comment
@ddfisher

ddfisher Aug 4, 2017

Collaborator

👍

Collaborator

ddfisher commented Aug 4, 2017

👍

@ilinum ilinum merged commit 8984321 into python:master Aug 4, 2017

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@ddfisher

This comment has been minimized.

Show comment
Hide comment
@ddfisher

ddfisher Aug 4, 2017

Collaborator

🎉

Collaborator

ddfisher commented Aug 4, 2017

🎉

@ilinum ilinum deleted the ilinum:tag-anys branch Aug 8, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment