-
Notifications
You must be signed in to change notification settings - Fork 172
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
rewrite NoneType to None #5
Comments
not sure if it's related but I also have applied the types and it generated |
@carljm can i take this one |
@m1schka Yeah, that's this bug. We have MonkeyType/monkeytype/stubs.py Line 327 in d36c344
NoneType at all in an annotation, it should always be translated to None .
@iamrajhans Sure, thank you! |
I wrote a test case for this. It happens when types like Optional[str, NoneType] or even more complex occur. def test_union_nonetype_annotation(self):
"""NoneType should always be rendered as None"""
sig = Signature.from_callable(UpdateSignatureHelper.has_annos)
sig = update_signature_args(sig, {'a': Dict[str, Dict[str, Union[str, NoneType]]]}, has_self=False,
ignore_existing_annotations=True)
stub = FunctionStub('test', sig, FunctionKind.MODULE)
expected = 'def test(a: Dict[str, Dict[str, Union[str, None]]], b) -> int: ...'
assert stub.render() == expected All the magic happens in render_annotations(): I'll submit a PR since this keeps biting me. |
No description provided.
The text was updated successfully, but these errors were encountered: