-1
from typing import Callable, Type, TypeVar

T = TypeVar("T")

def repo(class_: Type[T]) -> Callable:
    def instantiate(*args, **kwargs) -> T:
        return class_(*args, **kwargs)

    return instantiate

Code above throws "error: Too many arguments for 'object'" on pre-commit hook run but not on local run (python poetry run mypy repo.py).
Neither error message nor difference of behaviour between hook and local run make sense to me.
Any clue?

Thanks.

torek
  • 448,244
  • 59
  • 642
  • 775
Joe Catin
  • 33
  • 3
  • show your configuration, show the output, show the command you ran, show the versions of the tools you're using – anthony sottile Sep 02 '22 at 23:48
  • Note that Git doesn't do anything special in terms of Python paths during hook runs, so this is probably actually a shell (.bashrc, .profile, etc.) item. You might set up a path for yourself at the command line that you don't set up for other programs, thereby giving yourself a different `mypy` when you run it from the command line. – torek Sep 03 '22 at 02:15

1 Answers1

0

you've got a version mismatch between your two environments.

the one that is failing is mypy<=0.910:

$ mypy --version
mypy 0.910
$ mypy t.py
t.py:7: error: Too many arguments for "object"
Found 1 error in 1 file (checked 1 source file)

the one that's passing is mypy>0.910

$ mypy --version
mypy 0.971 (compiled: yes)
$ mypy t.py
Success: no issues found in 1 source file
anthony sottile
  • 61,815
  • 15
  • 148
  • 207