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
Minor improvements to convertors #902
Conversation
JayH5
commented
Apr 18, 2020
•
edited
edited
- typing: Make convertors generic over their return types.
- PathConvertor can inherit from StringConvertor
- Use r-strings for regex pattern literals.
raise NotImplementedError() # pragma: no cover | ||
|
||
def to_string(self, value: typing.Any) -> str: | ||
def to_string(self, value: Any) -> str: |
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.
It's not really clear to me what the type of value
is. Possibly it can also be T
, but the semantics of to_string
are not documented so I'm not sure.
Neat bit of work - thanks. It's a bit of a mixed bag if the Net result... we might just want to stick with simplicity and continue to under-specify the return type, as we currently do. Not sure. 🤷♂️ |
This reverts commit 5cbf16b.
Thanks for the thoughtful review. I think I agree that this doesn't add terribly much except checking that the convertors return the expected type. Seems like we're all still figuring out when typing is most useful in Python. I've reverted the change that made PathConvertor inherit from StringConvertor. I'll leave this for now but feel free to merge or close. Otherwise in a few days I'll close this. |