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-133653: Fix subclassing `HelpFormatter` by hugovk · Pull Request #133668 · python/cpython Conversation
|
| color=self.color, | ||
| ) | ||
| else: | ||
| except TypeError: |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
TypeError seems a bit generic (you're calling user code).
What do you think about this?
len([v.kind for (k, v) in inspect.signature(self.formatter_class).parameters.items() if k in ('y', 'z') and v.kind in (inspect._ParameterKind.POSITIONAL_OR_KEYWORD, inspect._ParameterKind.KEYWORD_ONLY)]) == 2
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.
That doesn't work: FAILED (failures=2, errors=156)
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.
Wait, it does, obviously need to replace y and z :)
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 would not like to use inspect.signature() here. It is not reliable. If it fails (or return incorrect result), you cannot do anything with this. It can only be used in interactive introspection, when errors can be ignored.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Would you prefer the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
No, I think the user code should be changed. They use undocumented feature. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
We can do my original suggestion - make Already two external libraries were broken by this in the first alpha testing. Leaving this as it is will break user code for sure. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
This would not help. The problem is that the user code does not accept any arguments besides |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
What's the concern with inspect? That it won't work for some weird function? In that case we can just use the default values for these arguments. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Another option is to set these fields through a setter method and not via |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
See alternative PR #133813. |
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.