-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Consistent quote wrapping around MessageBuilder.format as per issue #3409 #3430
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
Conversation
This was something I was looking for in the quick start, and didn't find clearly stated anywhere in the README.
Fixes python#3308 This PR adds better processing of "synthetic" types (``NewType``, ``NamedTuple``, ``TypedDict``) to the third pass and moves some processing from the second to the third pass.
* Add note for diff inffered and return type * Fix conditions for note * Move tests to newline * Style improvements and more detailed message * Fix tests * Move message function to messages * More test cases * Test different sequence * Cleaner separate of test cases
* Add type checking plugin support for functions The plugins allow implementing special-case logic for inferring the return type of certain functions with tricky signatures such as `open` in Python 3. Include plugins for `open` and `contextlib.contextmanager`. Some design considerations: - The plugins have direct access to mypy internals. The idea is that most plugins will be included with mypy so mypy maintainers can update the plugins as needed. - User-maintained plugins are currently not supported but could be added in the future. However, the intention is to not have a stable plugin API, at least initially. User-maintained plugins would have to track mypy internal API changes. Later on, we may decide to provide a more stable API if there seems to be a significant need. The preferred way would still be to keep plugins in the mypy repo. * Add test case for additional special cases * Fix handling of arguments other than simple positional ones Also add comments and some defensive checks.
Fix python#3393 This results in pytest output being shown as a passthrough at the beginning of runtests.py.
This will allow the links in python#3411 to be shorter.
Use entry_points instead of custom scripts (but custom scripts remain in case they are still useful).
Use case: type hierarchy of IDs, all of which are integers at runtime, but we want to type-check distinctions between e.g. "id of User" and "id of Media", while still allowing some functions to take "any ID" (which is still a more specific type than "any integer").
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for powering through all the tests! Just two tiny nits.
@@ -241,6 +241,12 @@ def format_simple(self, typ: Type, verbosity: int = 0) -> str: | |||
None -> None | |||
callable type -> "" (empty string) | |||
""" | |||
ret = self._format_simple(typ, verbosity) | |||
if ret == "Module": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should really use 'Module' here. (Also I really detest the messages "Module does not blah" -- I always need to know the module name. But that's a separate concern.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clarify... are you suggesting single quotes over double quotes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only one this one line in the source code. (In the output I am fine with the double quotes.) But the line of code that generates the special value 'Modules'
also uses single quotes, as does most of the surrounding code, so I'd like this line to be consistent.
if len(s) < 400: | ||
return s | ||
else: | ||
return 'union type ({} items)'.format(len(items)) | ||
elif isinstance(typ, NoneTyp): | ||
return 'None' | ||
elif isinstance(typ, AnyType): | ||
return '"Any"' | ||
return 'Any' | ||
elif isinstance(typ, DeletedType): | ||
return '<deleted>' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, I think it would look ugly to have "<deleted>"
in the error messages, and ditto for "<nothing>"
below. Maybe the code that adds the quotes should make an exception for strings starting with <
and ending with >
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<deleted>
was not part of this diff. Can we bump to another? This one is already a behemoth of test changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But IIUC this diff would change <deleted>
into "<deleted>"
which I think is wrong. So it's part of the diff. And there seem to be no tests with <deleted>
so there's no extra burden there. (Similar for <nothing>
.)
PS. Who's Brian Weber (bweber@twitter.com)? The commits are by him but the PR is by mistermocha. Are you the same person? |
Also please resolve the merge conflict. |
This gets rid of code duplication and makes sure mypy works with the released version of `typing`. This doesn't fix any immediate issue, but I saw some comments in the bug tracker saying that we should be able to get rid of `lib-typing` eventually. There is a minor downside: To run mypy tests locally, you will now have to have a Python 2.7 installed that has `typing` available.
Yes, I'm bweber@twitter.com as well as this account for @mistermocha. I have been working off of my work laptop for sprints. so my Test conflicts galore. After a pull/rebase/merge-conflict-resolve, I updated test data and got this:
... mutiple times. This doesn't seem right. |
After recent commits you need to install typing for Python 2 on your machine. |
Since you've now been outed you might as well update the full name and email on the GitHub account (AFAIK GitHub lets you register multiple email addresses). |
I don't know what you did, but you now have a bunch of unrelated commits in this PR. I expect you can fix that using rebase (but I don't know your setup so I can't give you more specific advice). |
Blocked until that can be fixed. Possibly you could save your diffs in an old-fashioned patch file outside your repo, get rid of your clone, get rid of the fork, create a new fork, clone that, and re-apply your patches using |
@mistermocha are you still working on this? this would help other PRs. |
Apologies, I've been tied up. I'll likely have time this weekend to wrap
up. If anyone has bandwidth to take over, I'm happy to hand off.
…On Tue, Aug 22, 2017 at 1:44 PM, Ivan Levkivskyi ***@***.***> wrote:
@mistermocha <https://github.com/mistermocha> are you still working on
this? this would help other PRs.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#3430 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ADnoGdPrDV-1hLHZv9lMzIpZqTr72PYUks5saz2pgaJpZM4NkWAi>
.
|
I've been taking a look at this, and I've resolved most of the conflicts. Will push up a branch later today. |
That branch is pushed and I've proposed it for merge at #3873. |
OK, I am closing this in favor of #3873 |
@mistermocha Thanks for your efforts! This PR was very helpful as a starting point. |
Well done! Happy to help!
…On Aug 25, 2017 5:49 AM, "Ivan Levkivskyi" ***@***.***> wrote:
@mistermocha <https://github.com/mistermocha> Thanks for your efforts!
This PR was very helpful as a starting point.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#3430 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ADnoGQ4vIeP_JzkpPCjjgm2wlTIYPMWOks5sbsLQgaJpZM4NkWAi>
.
|
This is a refreshed version of #3430 (credits @mistermocha). Fixes #3409. Tidying up inconsistent quotes around returned types for formatting. See #3409 for background.
Tidying up inconsistent quotes around returned types for formatting. See #3409 for background.