-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Need plugin hooks for functions/methods #6760
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
Comments
I like this idea, this will allow supporting some common dynamic features. This will likely require local lookup functions to the public API (currently it is there on |
JFI/bump: I wonder if this is only about having |
Brainstorming:
|
I was quite suprised this is not already the case, as I understand it exists for classes / methods with the What's the reasoning behind that decision? What would be needed to add such a hook? |
This looks like exactly what I am looking for here: https://gitter.im/python/typing?at=5efa750ee0e5673398e1aa81 TLDR: @kinded
def map_functor(
f: Kind[K, T],
function: Callable[[T], V],
) -> Kind[K, V]:
return f.map(function) This code currently does not typecheck, because it is not seem to be possible to tell what |
Related #9925 |
For some frameworks like
pytest
it would be useful to have a plugin that works with functions.Currently mypy has decorator hook for classes.
Some ideas for possible hooks:
For example pytest has the following fixture
The fixture is used by name:
db_path
argument here is a calucated the result ofdb_path()
fixture call.It is bound by parameter name which is the same as the fixture name.
Adding a type to
db_path
argument is tedious, especially if a fixture returns some complex type likeCallable[[str, int], Awaitable[web.Response]]
.Technically all needed information can be extracted from fixture definition if the definition is type annotated.
A plugin for pytest would be awesome but as @ilevkivskyi said
mypy
needs a new hook to support it.The text was updated successfully, but these errors were encountered: