Skip to content

Commit

Permalink
fix scipy and deserialising of False-like
Browse files Browse the repository at this point in the history
  • Loading branch information
Carreau committed Sep 27, 2023
1 parent 96ca1b2 commit 301a89f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
7 changes: 7 additions & 0 deletions examples/scipy.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ pypi = 'scipy'
homepage = 'https://scipy.org/'
docspage = 'https://docs.scipy.org/doc/scipy/'
[global.implied_imports]
scipy = 'scipy'
ua = 'scipy._lib.uarray'
array = 'numpy:array'
arange = 'numpy:arange'
Expand Down Expand Up @@ -100,6 +101,10 @@ VisitCitationReferenceNotImplementedError = [
"scipy.optimize._nonlin:Anderson",
"scipy.spatial._spherical_voronoi:calculate_solid_angles",
"scipy.special._orthogonal:_pbcf",
"scipy.special._orthogonal",
"scipy.optimize._lsq.dogbox",
"scipy.optimize._lsq.trf",
"scipy.stats._levy_stable:levy_stable_gen",
]
IncorrectInternalDocsLen = [
"scipy.signal._spline:symiirorder1",
Expand Down Expand Up @@ -146,6 +151,8 @@ NumpydocParseError = [
"scipy.stats._discrete_distns:betabinom_gen",
"scipy.stats._discrete_distns:geom_gen",
"scipy.stats._discrete_distns:planck_gen",
"scipy.special:btdtr",
"scipy.special:btdtri",
]
ExampleError1 = [
"scipy.stats._qmc:PoissonDisk",
Expand Down
6 changes: 4 additions & 2 deletions papyri/miniserde.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ def serialize(instance, annotation):
) from e


_sentinel = object()

# type_ and annotation are _likely_ duplicate here as an annotation is likely a type, or a List, Union, ....)
def deserialize(type_, annotation, data):
# assert type_ is annotation
Expand Down Expand Up @@ -208,8 +210,8 @@ def deserialize(type_, annotation, data):
try:
real_type = real_type[0]
except IndexError:
breakpoint()
if data.get("data"):
raise
if data.get("data", _sentinel) is not _sentinel:
data_ = data["data"]
else:
data_ = {k: v for k, v in data.items() if k != "type"}
Expand Down
6 changes: 4 additions & 2 deletions papyri/signature.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,17 @@ class Empty(Node):

_empty = Empty()

NoneType = type(None)


@register(4030)
@dataclass
class ParameterNode(Node):
name: str
# we likely want to make sure annotation is a structured object in the long run
annotation: Union[str, None, Empty]
annotation: Union[str, NoneType, Empty]
kind: str
default: Union[str, None, Empty]
default: Union[str, NoneType, Empty]

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
Expand Down

0 comments on commit 301a89f

Please sign in to comment.