Skip to content

Invalid type for inverted IntFlag #13853

Closed
@zoola969

Description

@zoola969

Bug Report

A type of inverted IntFlag is revealed as int instead of IntFlag

To Reproduce

from enum import IntFlag


class F(IntFlag):
    A = 1
    B = 2


reveal_type(F.A | F.B)
reveal_type(~F.A)

Expected Behavior

Revealed type is "F"
Revealed type is "F"

Actual Behavior

Revealed type is "F"
Revealed type is "builtins.int"

Your Environment

  • Mypy version used: 1.15.0
  • Mypy command-line flags:
  • Mypy configuration options from pyproject.toml:
[tool.mypy]
check_untyped_defs = true
enable_error_code = "explicit-override,unused-awaitable,ignore-without-code,truthy-bool,possibly-undefined,redundant-expr,redundant-self"
plugins = ["pydantic.mypy"]
pretty = true
show_error_context = true
strict = true
warn_unreachable = true

[tool.pydantic-mypy]
init_forbid_extra = true
init_typed = true
warn_required_dynamic_aliases = true
  • Python version used:

3.13

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      X