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

Unsupported operand type for ~ ("auto") #18410

Open
edgarrmondragon opened this issue Jan 2, 2025 · 0 comments
Open

Unsupported operand type for ~ ("auto") #18410

edgarrmondragon opened this issue Jan 2, 2025 · 0 comments
Labels
bug mypy got something wrong topic-enum

Comments

@edgarrmondragon
Copy link
Contributor

Bug Report

Starting with mypy 1.14.0, we started getting an error for an enum class that defines a member as an inversion (i.e. ~) of a different member that is declared with enum.auto().

To Reproduce

import enum


class Example(enum.Flag):
    USER = enum.auto()
    ADMIN = enum.auto()
    MACHINE = enum.auto()

    HUMAN = ~MACHINE

Playground links:

  1. https://mypy-play.net/?mypy=1.14.1&python=3.13 (fails)
  2. https://mypy-play.net/?mypy=1.13.0&python=3.13 (succeeds)

Expected Behavior

The operator should be supported for enum.Flag "auto" members.

Actual Behavior

enum_typing_repro.py:9: error: Unsupported operand type for ~ ("auto")  [operator]
Found 1 error in 1 file (checked 1 source file)

FWIW I wonder if this is related to recent changes in typeshed: python/typeshed@3e29e05.

Your Environment

  • Mypy version used: 1.14.1
  • Mypy command-line flags:
  • Mypy configuration options from mypy.ini (and other config files):
  • Python version used: 3.13
@edgarrmondragon edgarrmondragon added the bug mypy got something wrong label Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong topic-enum
Projects
None yet
Development

No branches or pull requests

2 participants