Skip to content

Handling of __new__ ? #5214

Closed
Closed
@rbtcollins

Description

@rbtcollins

Note: if you are reporting a wrong signature of a function or a class in
the standard library, then the typeshed tracker is better suited
for this report: https://github.com/python/typeshed/issues

Please provide more information to help us understand the issue:

  • Are you reporting a bug, or opening a feature request?

Feature request or bug, one or other :).

  • Please insert below the code you are checking with mypy,
    or a mock-up repro if the source is private. We would appreciate
    if you try to simplify your case to a minimal repro.
# 3.5 compatible syntax
_Example= NamedTuple("Example", [("field", str)])

# Customise to permit optional parameters
class Example(_Example):
    def __new__(cls, *, field=None):
        if field is None:
           field = "default"
        return super().__new__(cls, field=field)

Example()
  • What is the actual behavior/output?
    error: too few arguments...
  • What is the behavior/output you expect?
    no error
  • What are the versions of mypy and Python you are using?
    mypy 0.6
    Python 3.5 and 3.6
    Do you see the same issue after installing mypy from Git master?
    Haven't tested
  • What are the mypy flags you are using? (For example --strict-optional)
    --ignore-missing-imports

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