Special methods such as `object.__del__` should have pre-defined types

Open
#3,056 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
python
Domain
devtools

Research direction

Read the Python data model documentation linked in the issue, then locate mypy's handling and tests for special methods such as del. Use the two examples as behavioral cases: both invalid signatures should be rejected, including the extra parameter and the incompatible return annotation.

Written by the indexing model from the issue text.

Description

feature

This should be rejected, for example

class C(object):
  def __del__(self, a):
    # type: (int) -> int
    return a

Probably this as well

class C(object):
  def __del__(self):
    # type: () -> int
    return 0

Cf. https://docs.python.org/3/reference/datamodel.html#basic-customization

Dominant language
Python
Stars
20.6k
Forks
3.3k
Avg merge
1d 18h
Merged PRs (30d)
54

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.

More from python/mypy

All issues in python/mypy

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.