Skip to content
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

Stop generating Python 2-style enums #1221

Closed
tjprescott opened this issue Apr 7, 2022 · 1 comment
Closed

Stop generating Python 2-style enums #1221

tjprescott opened this issue Apr 7, 2022 · 1 comment
Assignees

Comments

@tjprescott
Copy link
Member

from enum import Enum
from six import with_metaclass
from azure.core import CaseInsensitiveEnumMeta

class Answers(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
    NONE = "none"
    EXTRACTIVE = "extractive"

If you try and run pylint on this, it will crash with an error that "Const is not iterable". (See: pylint-dev/pylint#5935)

Even if pylint fixes the error, we are pinned to pylint 2.5.2 and this still happens there.

This does not affect our SDKs much because most of these enums live in the _generated folder, which is skipped by our pylint rcfile. However, if someone follows our generated code and creates a manual enum, they will observe this behavior. Since we no longer support Python 2, we should start generating these enums with the Python 3 syntax, which is pylint-compatible:

from enum import Enum
from azure.core import CaseInsensitiveEnumMeta

class Answers(str, Enum, metaclass=CaseInsensitiveEnumMeta):
    NONE = "none"
    EXTRACTIVE = "extractive"

cc/ @lmazuel @l0lawrence @kashifkhan

@tjprescott tjprescott changed the title Stop generatiung Python 2-style enums Stop generating Python 2-style enums Apr 7, 2022
@iscai-msft iscai-msft assigned msyyc and changlong-liu and unassigned iscai-msft Apr 7, 2022
@iscai-msft
Copy link
Contributor

fixed by #1202 and released in 5.15.0

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

No branches or pull requests

4 participants