Correct variable typing in models py3 file for python 3.5#691
Correct variable typing in models py3 file for python 3.5#691iscai-msft merged 4 commits intoautorestv3from
Conversation
| elif prop.is_discriminator: | ||
| discriminator_value = f"'{model.discriminator_value}'" if model.discriminator_value else None | ||
| init_args.append(f"self.{prop.name} = {discriminator_value}") | ||
| if not discriminator_value: |
There was a problem hiding this comment.
discriminator is required, the base class will have None (all the time), and it will be a constant (all the time) in sub-classes. Optional[str] sounds incorrect
There was a problem hiding this comment.
Sounds good. We originally had the Optional[str] for the base class, let me switch that to None. Thanks!
There was a problem hiding this comment.
Just tried to switch it to None for base class definitions of None, but that's throwing a mypy error, because the typing for the base class needs to encompass the typing of the discriminator in both the base class and the children classes. I think it needs to be left as Optional[str] for the base class. Here's the mypy error:
Incompatible types in assignment (expression has type "str", base class "Fish" defined the type as "None")
…into fix_variable_typing_py35 * 'autorestv3' of https://github.com/Azure/autorest.python: Data plane multiapi (#693) Lro and paging (iscai style) (#689)
…into make_enums_uppercase * 'autorestv3' of https://github.com/Azure/autorest.python: Correct variable typing in models py3 file for python 3.5 (#691) Data plane multiapi (#693) Lro and paging (iscai style) (#689)
…into add_nullable_to_validation_map * 'autorestv3' of https://github.com/Azure/autorest.python: Update package.json Update ChangeLog.md Correct variable typing in models py3 file for python 3.5 (#691) Data plane multiapi (#693) Lro and paging (iscai style) (#689)
fixes #690