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

Overload fails on Optional arguments #90

Closed
ipcoder opened this issue Mar 27, 2023 · 1 comment
Closed

Overload fails on Optional arguments #90

ipcoder opened this issue Mar 27, 2023 · 1 comment

Comments

@ipcoder
Copy link

ipcoder commented Mar 27, 2023

Version 1.9.1 python 3.9

Code below fails if annotations is imported:

from __future__ import annotations
from multimethod import  overload

@overload
def g(x: int, c: str = None):
    print(x, c)

@overload
def g(c: str):
    print(c)

print('overload')
g(1)
g('10')
g(11, '12')   # fails HERE
coady added a commit that referenced this issue Mar 30, 2023
Generic aliases pass as `callable`, even though they are not. A related issue found in #90: prior to Python 3.11, a parameter with a default of `None` was automatically coerced to `Optional` by `get_type_hints`.
mfkaptan pushed a commit to mfkaptan/pandera that referenced this issue Jul 3, 2023
Making `key` argument optional did not work because of an existing
bug in multimethod: coady/multimethod#90
Added a second overloaded `preprocess` method that has `key=None`
so multimethod lib can dispatch correctly.
mfkaptan pushed a commit to mfkaptan/pandera that referenced this issue Jul 21, 2023
Making `key` argument optional did not work because of an existing
bug in multimethod: coady/multimethod#90
Added a second overloaded `preprocess` method that doesn't have `key`
arg so multimethod lib can dispatch correctly.
Same with apply function.

Signed-off-by: mfkaptan <mustafa.kaptan@motius.de>
cosmicBboy added a commit to unionai-oss/pandera that referenced this issue Aug 11, 2023
* Add tests for pyspark dataframemodel custom checks

Signed-off-by: mfkaptan <mustafa.kaptan@motius.de>

* Add a second overloaded preprocess method

Making `key` argument optional did not work because of an existing
bug in multimethod: coady/multimethod#90
Added a second overloaded `preprocess` method that doesn't have `key`
arg so multimethod lib can dispatch correctly.
Same with apply function.

Signed-off-by: mfkaptan <mustafa.kaptan@motius.de>

* Fix isinstance call with adding type of the BooleanType

Signed-off-by: mfkaptan <mustafa.kaptan@motius.de>

---------

Signed-off-by: mfkaptan <mustafa.kaptan@motius.de>
Co-authored-by: mfkaptan <mustafa.kaptan@motius.de>
@coady
Copy link
Owner

coady commented Sep 17, 2023

Fix will be in the next release.

@coady coady closed this as completed Sep 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants