Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Argument X of "Y" incompatible with supertype "Z" - needs more detail #5025

Closed
remdragon opened this issue May 13, 2018 · 3 comments · Fixed by #6796
Closed

Argument X of "Y" incompatible with supertype "Z" - needs more detail #5025

remdragon opened this issue May 13, 2018 · 3 comments · Fixed by #6796

Comments

@remdragon
Copy link

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

feature request. Presumably mypy has the type information from the supertype available and at hand. It would be extremely helpful if that information was included in the diagnostics so that I don't have to go hunting for it.

  • 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.
import datetime
class Tzoffset ( datetime.tzinfo ):
	_delta = _tzname = None
	def __init__ ( self, delta, tzname='' ):
		# type: ( datetime.timedelta, str ) -> None
		assert isinstance ( delta, datetime.timedelta )
		self._delta = delta
		self._tzname = tzname
	def utcoffset ( self, dt ):
		# type: ( datetime.datetime ) -> datetime.timedelta
		return self._delta
	def dst ( self, dt ):
		# type: ( datetime.datetime ) -> datetime.timedelta
		return self._delta
	def tzname ( self, dt ):
		# type: ( datetime.datetime ) -> str
		return self._tzname
  • What is the actual behavior/output?

error: Argument 1 of "tzname" incompatible with supertype "tzinfo"

  • What is the behavior/output you expect?

error: Argument 1 of "tzname" incompatible with supertype "tzinfo"; expected "foo"

  • What are the versions of mypy and Python you are using?
    Do you see the same issue after installing mypy from Git master?

Python 2.7.14 (v2.7.14:84471935ed, Sep 16 2017, 20:19:30) [MSC v.1500 32 bit (Intel)] on win32
Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:04:45) [MSC v.1900 32 bit (Intel)] on win32
mypy 0.600
dunno how to check git master

  • What are the mypy flags you are using? (For example --strict-optional)

mypy --py2 %1 --ignore-missing-imports --disallow-untyped-defs
mypy %1 --ignore-missing-imports --disallow-untyped-defs

  • If mypy crashed with a traceback, please paste
    the full traceback below.

(n/a)

@ilevkivskyi
Copy link
Member

Note there is a proposal to add more info for errors like this behind a flag #4835

@remdragon
Copy link
Author

remdragon commented May 24, 2018 via email

@matys18
Copy link
Contributor

matys18 commented May 7, 2019

Taking a look at this

ilevkivskyi pushed a commit that referenced this issue May 8, 2019
Closes #5025

Updated the error message that is displayed when the argument types of a method in a subclass are incompatible with the arguments of the same method in the superclass.

```python
# sample.py

class A:

    def kek(self, lol: int = 0) -> None:
        print("Kek in A")


class B(A):

    def kek(self, haha: str = "") -> None:
        super().kek(1)
        print("Kek in B")
```

Output before:
```sh
mypy sample.py
sample.py:11: error: Argument 1 of "kek" incompatible with supertype "A"
```

Output now:
```
mypy sample.py
sample.py:11: error: Argument 1 of "kek" is incompatible with supertype "A"; supertype defines the argument type as "int"
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants