Skip to content

Correct variable typing in models py3 file for python 3.5#691

Merged
iscai-msft merged 4 commits intoautorestv3from
fix_variable_typing_py35
Jun 18, 2020
Merged

Correct variable typing in models py3 file for python 3.5#691
iscai-msft merged 4 commits intoautorestv3from
fix_variable_typing_py35

Conversation

@iscai-msft
Copy link
Contributor

fixes #690

@iscai-msft iscai-msft requested a review from lmazuel June 15, 2020 19:01
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:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good. We originally had the Optional[str] for the base class, let me switch that to None. Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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")

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, that's ok then

…into fix_variable_typing_py35

* 'autorestv3' of https://github.com/Azure/autorest.python:
  Data plane multiapi (#693)
  Lro and paging (iscai style) (#689)
@iscai-msft iscai-msft merged commit 0db9e76 into autorestv3 Jun 18, 2020
@iscai-msft iscai-msft deleted the fix_variable_typing_py35 branch June 18, 2020 20:05
iscai-msft added a commit that referenced this pull request Jun 26, 2020
…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)
iscai-msft added a commit that referenced this pull request Sep 10, 2020
…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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants