This repository was archived by the owner on Jun 10, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +7
-10
lines changed Expand file tree Collapse file tree 2 files changed +7
-10
lines changed Original file line number Diff line number Diff line change 11from mypy .nodes import ARG_POS
22from mypy .plugin import Plugin
33from mypy .types import CallableType
4-
5- UFUNC_ARITIES = {
6- 'sin' : 1 ,
7- }
4+ import numpy as np
85
96
107def ufunc_call_hook (ctx ):
118 ufunc_name = ctx .context .callee .name
12- arity = UFUNC_ARITIES . get ( ufunc_name )
13- if arity is None :
9+ ufunc = getattr ( np , ufunc_name , None )
10+ if ufunc is None :
1411 # No extra information; return the signature unmodified.
1512 return ctx .default_signature
1613
1714 # Strip off the *args and replace it with the correct number of
1815 # positional arguments.
19- arg_kinds = [ARG_POS ] * arity + ctx .default_signature .arg_kinds [1 :]
16+ arg_kinds = [ARG_POS ] * ufunc . nin + ctx .default_signature .arg_kinds [1 :]
2017 arg_names = (
21- [f'x{ i } ' for i in range (arity )] +
18+ [f'x{ i } ' for i in range (ufunc . nin )] +
2219 ctx .default_signature .arg_names [1 :]
2320 )
2421 arg_types = (
25- [ctx .default_signature .arg_types [0 ]] * arity +
22+ [ctx .default_signature .arg_types [0 ]] * ufunc . nin +
2623 ctx .default_signature .arg_types [1 :]
2724 )
2825 return ctx .default_signature .copy_modified (
Original file line number Diff line number Diff line change 11[mypy]
2- plugins = numpy_ufuncs_plugin
2+ plugins = numpy_ufuncs_plugin
You can’t perform that action at this time.
0 commit comments