GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Constrain/narrow literal type with 'in' checks · Issue #9718 · python/mypy

Constrain/narrow literal type with 'in' checks #9718

New issue
Copy link
New issue
Copy link
Closed as not planned
Closed as not planned
Constrain/narrow literal type with 'in' checks#9718
Copy link
Labels
featurepriority-1-normaltopic-literal-typestopic-type-narrowingConditional type narrowing / binder

Description

@KotlinIsland
KotlinIsland
opened on Nov 13, 2020
Issue body actions
from typing import Literal

a: Literal[1, 2, 3] = 2
assert a in (1, 2)
b: Literal[1, 2] = a
error: Incompatible types in assignment (expression has type "Union[Literal[1], Literal[2], Literal[3]]", variable has 
type "Union[Literal[1], Literal[2]]")
    b: Literal[1, 2] = a
                       ^
Reacted by Huon Wilson, Marti Raudsepp, IvarVirusiim and Fabian Keller

Activity

  1. KotlinIsland
    added
    bugmypy got something wrong
    on Nov 13, 2020
  2. prayatharth commented on Nov 13, 2020

    @prayatharth
    prayatharth
    on Nov 13, 2020
    More actions

    What problem exactly we are facing here ?

  3. JelleZijlstra commented on Nov 13, 2020

    @JelleZijlstra
    JelleZijlstra
    on Nov 13, 2020
    Member
    More actions

    The report seems clear enough to me. It's a reasonable request; a PR would be welcome.

  4. hauntsaninja
    added
    feature
    and removed
    bugmypy got something wrong
    on Nov 13, 2020
  5. 97littleleaf11
    added
    topic-literal-types
    priority-1-normal
    on Feb 19, 2022
  6. AlexWaygood
    added
    topic-type-narrowingConditional type narrowing / binder
    on Jul 8, 2022
  7. hauntsaninja commented on Nov 12, 2023

    @hauntsaninja
    hauntsaninja
    on Nov 12, 2023
    Collaborator
    More actions

    Duplicate of #12535

  8. hauntsaninja
    marked this as a duplicate of Narrowing types to Literal using in syntax #12535 on Nov 12, 2023
  9. hauntsaninja
    closed this as not plannedon Nov 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    featurepriority-1-normaltopic-literal-typestopic-type-narrowingConditional type narrowing / binder

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.