GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — gh-100129: Make the names of all classes in the types module resolvable by serhiy-storchaka · Pull Request #100130 · python/cpython Conversation
|
Agreed. I'm broadly supportive of this change, but the change to |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I have a few nits -- feel free to address or ignore those.
I'd like @JelleZijlstra or another typeshed/mypy dev to have a quick look here to see whether changing a few names like function, ellipsis would cause any issues for static type checkers (though I doubt it).
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| >>> mock = MagicMock(async_func) | ||
| >>> mock | ||
| <MagicMock spec='function' id='...'> | ||
| <MagicMock spec='FunctionType' id='...'> |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Why not types.FunctionType?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Because the MagicMock repr contains only spec_class.__name__, not the fully qualified name.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| import sys | ||
| with self.assertRaisesRegex(TypeError, | ||
| 'Object of type module is not JSON serializable'): | ||
| 'Object of type ModuleType is not JSON serializable'): |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Why is this not types.ModuleType?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The same as above. It outputs type(obj).__name__.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| PyObject *obj = NULL; | ||
|
|
||
| if (!_PyArg_NoKeywords("cell", kwargs)) { | ||
| if (!_PyArg_NoKeywords("CellType", kwargs)) { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
It's debatable whether this should have the types. prefix -- what do we do in other similar situations?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Only short name is used in almost all of other similar situations (over 50 uses of this function, around 1700 uses of all PyArg_* functions). The only known exceptions are array.array, sqlite3.Connection, type.__new__, and deque.rotate.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Fully static type checkers like mypy never look at the runtime type objects so it shouldn't matter. Tools like stubtest or my pyanalyze typechecker might need to adapt a little but that's pretty easy. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
I was thinking about it slightly differently. Typeshed defines classes def f(): pass func: function = f There was some precedent for this when import types func: types.FunctionType = f which currently produces an error in mypy. (In a sense, this PR finally resolves a problem that mypy experienced from its creation: what is the name of the type of a function object. Grepping shows dozens of occurrences of I agree that we shouldn't stop this PR because it exposes mypy's "lie". :-) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks for the answers, go ahead and merge. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
What do you think about omitting the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
This is going to break things. Changing the names There are a lot of changes to the tests. If this change breaks our tests, it is reasonable to assume it will break other people's tests. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I'm happy to retract my approval in favor of more discussion -- maybe we should do that on Discourse though, where we can get the view of more people whose code actually will break. I agree that the amount of change needed in our own tests doesn't bode well. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Just to note: the new-in-3.13 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
This PR is stale because it has been open for 30 days with no activity. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Documentation build overview
8 files changed ·
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
This PR is stale because it has been open for 90 days with no activity. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.