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

Fix per-file strict Optional interaction with default-None args #3686

Merged
merged 3 commits into from Jul 19, 2017

Conversation

Projects
None yet
2 participants
@ddfisher
Collaborator

ddfisher commented Jul 10, 2017

With per-file strict Optional, default-None args should always be interpreted as Optional (except with --no-implicit-optional), instead of only in strict Optional files.

@gvanrossum gvanrossum referenced this pull request Jul 18, 2017

Closed

Release mypy 0.521 #3732

JukkaL added a commit that referenced this pull request Jul 18, 2017

Remove unnecessary methods in typing stub (#3734)
Helpful for the right fix in #3686.
@ddfisher

This comment has been minimized.

Show comment
Hide comment
@ddfisher

ddfisher Jul 18, 2017

Collaborator

@gvanrossum this should be ready to review now!

Collaborator

ddfisher commented Jul 18, 2017

@gvanrossum this should be ready to review now!

@gvanrossum

LG, a few style nits.

strict_optional = False
[[mypy-optional]
strict_optional = True

This comment has been minimized.

@gvanrossum

gvanrossum Jul 18, 2017

Member

You don't really need three blank lines here, just one. :-) Also IMO you can drop the single blank lines above.

@gvanrossum

gvanrossum Jul 18, 2017

Member

You don't really need three blank lines here, just one. :-) Also IMO you can drop the single blank lines above.

This comment has been minimized.

@ddfisher

ddfisher Jul 18, 2017

Collaborator

Fixed the three blank lines. The lines between the files make them much more readable to me (though it looks like one got dropped, so I added it back).

@ddfisher

ddfisher Jul 18, 2017

Collaborator

Fixed the three blank lines. The lines between the files make them much more readable to me (though it looks like one got dropped, so I added it back).

@@ -363,7 +363,7 @@ y = x # E: Incompatible types in assignment (expression has type Callable[...,
a, b = None, None # type: (A, B)
a = f() # E: Incompatible types in assignment (expression has type "B", variable has type "A")
b = f(b) # E: Argument 1 to "f" has incompatible type "B"; expected "A"
b = f(b) # E: Argument 1 to "f" has incompatible type "B"; expected "Optional[A]"

This comment has been minimized.

@gvanrossum

gvanrossum Jul 18, 2017

Member

I wonder if it makes more sense to change the definition of f() to use A() as the default value? Ditto for the next test below.

@gvanrossum

gvanrossum Jul 18, 2017

Member

I wonder if it makes more sense to change the definition of f() to use A() as the default value? Ditto for the next test below.

This comment has been minimized.

@ddfisher

ddfisher Jul 18, 2017

Collaborator

It looks to me like those functions are partially testing forward references? (Not sure why they'd be structured like that otherwise.) I can't use A() when it's a forward reference.

@ddfisher

ddfisher Jul 18, 2017

Collaborator

It looks to me like those functions are partially testing forward references? (Not sure why they'd be structured like that otherwise.) I can't use A() when it's a forward reference.

This comment has been minimized.

@gvanrossum

gvanrossum Jul 19, 2017

Member

Hm, I think that's just how Jukka used to write tests, with the classes/functions at the end. A lot of them have that. Anyway I'll merge now!

@gvanrossum

gvanrossum Jul 19, 2017

Member

Hm, I think that's just how Jukka used to write tests, with the classes/functions at the end. A lot of them have that. Anyway I'll merge now!

@gvanrossum gvanrossum merged commit 8709da5 into master Jul 19, 2017

3 checks passed

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

@gvanrossum gvanrossum deleted the fix-none-args branch Jul 19, 2017

@gvanrossum

This comment has been minimized.

Show comment
Hide comment
@gvanrossum

gvanrossum Jul 19, 2017

Member

Should be cherry-picked into 0.521.

Member

gvanrossum commented Jul 19, 2017

Should be cherry-picked into 0.521.

gvanrossum added a commit to gvanrossum/mypy that referenced this pull request Jul 24, 2017

gvanrossum added a commit to gvanrossum/mypy that referenced this pull request Jul 24, 2017

Fix per-file strict Optional interaction with default-None args (#3686)
With per-file strict Optional, default-None args should always be interpreted as Optional (except with --no-implicit-optional), instead of only in strict Optional files.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment