[issue46170] Improving the error message when subclassing NewType

2022-03-07 Thread Jelle Zijlstra
Change by Jelle Zijlstra : -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker ___

[issue46170] Improving the error message when subclassing NewType

2022-03-07 Thread Jelle Zijlstra
Jelle Zijlstra added the comment: New changeset f391f9bf28f0bba7939d9f9e5a7a6396d2b0df62 by James Hilton-Balfe in branch 'main': bpo-46170: Improve the error message when subclassing NewType (GH-30268) https://github.com/python/cpython/commit/f391f9bf28f0bba7939d9f9e5a7a6396d2b0df62

[issue46170] Improving the error message when subclassing NewType

2021-12-26 Thread Nikita Sobolev
Nikita Sobolev added the comment: Turns out modern docs already have this problem fixed: https://docs.python.org/3/library/typing.html#newtype -- ___ Python tracker ___

[issue46170] Improving the error message when subclassing NewType

2021-12-26 Thread Nikita Sobolev
Nikita Sobolev added the comment: > So maybe those docs are incorrect? I can't find anything in PEP 484 about > this. Mypy even has an explicit test that NewType of NewType should work:

[issue46170] Improving the error message when subclassing NewType

2021-12-26 Thread Guido van Rossum
Guido van Rossum added the comment: Weird, the docs you cite claims # Also does not typecheck ProUserId = NewType('ProUserId', UserId) but when I try it, it works at runtime and passes mypy (even with --strict) and also pyright. So maybe those docs are incorrect? I can't find

[issue46170] Improving the error message when subclassing NewType

2021-12-26 Thread Gobot1234
Gobot1234 added the comment: > Do you have evidence that people make this particular mistake often? And that > the suggested solution is indeed what they should use? Why would you want to > subclass UserId? I was just trying to implement something that I thought had a non-obvious error

[issue46170] Improving the error message when subclassing NewType

2021-12-26 Thread Guido van Rossum
Guido van Rossum added the comment: Do you have evidence that people make this particular mistake often? And that the suggested solution is indeed what they should use? Why would you want to subclass UserId? Do we have examples of other error messages split across two lines like this?

[issue46170] Improving the error message when subclassing NewType

2021-12-26 Thread Gobot1234
Change by Gobot1234 : -- keywords: +patch pull_requests: +28485 stage: -> patch review pull_request: https://github.com/python/cpython/pull/30268 ___ Python tracker ___

[issue46170] Improving the error message when subclassing NewType

2021-12-26 Thread Alex Waygood
Change by Alex Waygood : -- nosy: +AlexWaygood ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue46170] Improving the error message when subclassing NewType

2021-12-26 Thread Nikita Sobolev
Nikita Sobolev added the comment: > I'd be happy to patch this myself if this sounds like a good idea. Oh, please, go ahead! :) Would be happy to review. -- ___ Python tracker

[issue46170] Improving the error message when subclassing NewType

2021-12-26 Thread Nikita Sobolev
Nikita Sobolev added the comment: This seems like a good idea to me. I will send a PR for others to judge :) -- nosy: +sobolevn ___ Python tracker ___

[issue46170] Improving the error message when subclassing NewType

2021-12-23 Thread Gobot1234
New submission from Gobot1234 : I'd like to propose making the error message when subclassing typing.NewType much more understandable. Currently it looks like: ``` TypeError: NewType.__init__() takes 3 positional arguments but 4 were given ``` But I think we could do much better by adding