Skip to content
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

Use --no-implicit-optional for type checking #4378

Closed
wants to merge 3 commits into from

Conversation

hauntsaninja
Copy link
Contributor

Change Summary

This makes type checking PEP 484 compliant (as of 2018).
mypy will change its defaults soon.

See:
python/mypy#9091
python/mypy#13401

Checklist

  • Unit tests for the changes exist
  • Tests pass on CI and coverage remains at 100%
  • Documentation reflects the changes where applicable
  • changes/<pull request or issue id>-<github username>.md file added describing change
    (see changes/README.md for details)
  • My PR is ready to review, please add a comment including the phrase "please review" to assign reviewers

This makes type checking PEP 484 compliant (as of 2018).
mypy will change its defaults soon.

See:
python/mypy#9091
python/mypy#13401
@hauntsaninja
Copy link
Contributor Author

please review :-)

Copy link
Member

@samuelcolvin samuelcolvin left a comment

Choose a reason for hiding this comment

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

Otherwise looks good, thank you.

Please update.

@@ -0,0 +1 @@
Use ``--no-implicit-optional`` for type checking.
Copy link
Member

Choose a reason for hiding this comment

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

This is markdown, not rst.

@hauntsaninja
Copy link
Contributor Author

I fixed the markdown, but it looks like tests on Python 3.8 are failing with a weird Literal[None] issue. I see the code to work around this — was that issue flaky or has something about my change reactivated it?

@samuelcolvin
Copy link
Member

That's very weird, but I haven't seen that test being flakey before. I think it much be caused by your change, or be new.

@samuelcolvin
Copy link
Member

I don't see it on other newer builds, so it must be caused by your changes.

@hauntsaninja
Copy link
Contributor Author

I'll take a detailed look at it, but if I can't figure it out, how would you feel about potentially using the 3.7 code for 3.8 as well? If it can be activated by this seemingly no-op change, there may be a real issue here.

https://github.com/hauntsaninja/pydantic/blob/dab478aa81a59e0a5c69a0fe57bfe34f233994ff/pydantic/typing.py#L319

@samuelcolvin
Copy link
Member

It looks like we have a custom implementation for a reason, but if it's really not necessary, we could remove it.

@samuelcolvin
Copy link
Member

Notice

See twitter 🐦, I've you'd like this to be included in V1.10, please fix it and request a review TODAY.

Or if you need this in V1.10 but don't have time to complete it (or aren't the author), please comment here and on #4324

@samuelcolvin
Copy link
Member

Let's wait and adopt this in the V2 codebase.

@samuelcolvin samuelcolvin added deferred deferred until future release or until something else gets done and removed awaiting author revision labels Aug 22, 2022
@Fokko
Copy link

Fokko commented Aug 22, 2022

Great to see this happening! 👍🏻 Don't forget to add py.typed: https://peps.python.org/pep-0561/#packaging-type-information

@samuelcolvin
Copy link
Member

We've had a py.typed file since 2017?

@Fokko
Copy link

Fokko commented Aug 22, 2022

@samuelcolvin ah missed that one. I expected it to be on the root level. 👍🏻

@samuelcolvin
Copy link
Member

The code base will change too much for V2 to keep this pr, but I'm tracking the issue in #4424

@hauntsaninja hauntsaninja deleted the implicit-optional branch August 23, 2022 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deferred deferred until future release or until something else gets done
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants