python / python/mypy

`Enum` and `NamedTuple` should not allow extra keywords

Open
#16,521 5 comments 0 reactions 1 assignee View on GitHub

@sobolevn is already working on this.

Since Nov 18, 2023.

bug topic-enum topic-named-tuple
Dominant language
Python
Stars
20.6k
Forks
3.3k
PR merge metrics
PR metrics pending

Description

This code produces no error:

from typing import NamedTuple

class A(type): ...

class Foo(NamedTuple, metaclass=A, x=1):
   x: int
   
   
from enum import Enum

class E(Enum, x=1):
    a = 1

It is much easier with the NamedTuple, but, I think that enum might allow some keywords like boundary=STRICT.

So, I think that I will split the PRs for these two problems.

Refs https://github.com/python/mypy/issues/16432

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.