Skip to content

Marks unique enums as @unique #11181

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

Merged
merged 1 commit into from
Sep 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion mypy/modulefinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import re
import subprocess
import sys
from enum import Enum
from enum import Enum, unique

from typing import Dict, Iterator, List, NamedTuple, Optional, Set, Tuple, Union
from typing_extensions import Final
Expand Down Expand Up @@ -41,6 +41,7 @@
# TODO: Consider adding more reasons here?
# E.g. if we deduce a module would likely be found if the user were
# to set the --namespace-packages flag.
@unique
class ModuleNotFoundReason(Enum):
# The module was not found: we found neither stubs nor a plausible code
# implementation (with or without a py.typed file).
Expand Down
4 changes: 2 additions & 2 deletions mypy/nodes.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Abstract syntax tree node classes (i.e. parse tree)."""

import os
from enum import Enum
from enum import Enum, unique
from abc import abstractmethod
from mypy.backports import OrderedDict
from collections import defaultdict
Expand Down Expand Up @@ -1521,7 +1521,7 @@ def accept(self, visitor: ExpressionVisitor[T]) -> T:


# Kinds of arguments

@unique
class ArgKind(Enum):
# Positional argument
ARG_POS = 0
Expand Down
3 changes: 2 additions & 1 deletion mypyc/irbuild/format_str_tokenizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from typing import List, Tuple, Optional
from typing_extensions import Final
from enum import Enum
from enum import Enum, unique

from mypy.checkstrformat import (
parse_format_value, ConversionSpecifier, parse_conversion_specifiers
Expand All @@ -22,6 +22,7 @@
from mypyc.primitives.str_ops import str_build_op, str_op


@unique
class FormatOp(Enum):
"""FormatOp represents conversion operations of string formatting during
compile time.
Expand Down