Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
Carreau committed Oct 2, 2023
1 parent 8a5c928 commit b181267
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
1 change: 1 addition & 0 deletions papyri/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@
import typer

from . import examples

__version__ = "0.0.8"

logo = r"""
Expand Down
1 change: 1 addition & 0 deletions papyri/miniserde.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ def serialize(instance, annotation):

_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
17 changes: 12 additions & 5 deletions papyri/signature.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import inspect

from dataclasses import dataclass
from typing import Optional, List, Any, Dict, Union
from .common_ast import Node, validate
from typing import List, Any, Dict, Union
from .common_ast import Node
from .errors import TextSignatureParsingFailed

from .common_ast import register
Expand Down Expand Up @@ -35,9 +35,12 @@ def to_parameter(self) -> inspect.Parameter:
name=self.name,
kind=getattr(inspect._ParameterKind, self.kind),
default=inspect._empty if isinstance(self.default, Empty) else None,
annotation=inspect._empty if isinstance(self.annotation, Empty) else self.annotation,
annotation=inspect._empty
if isinstance(self.annotation, Empty)
else self.annotation,
)


@register(4029)
class SignatureNode(Node):
kind: str # maybe enum, is it a function, async generator, generator, etc.
Expand Down Expand Up @@ -100,9 +103,13 @@ def to_node(self) -> SignatureNode:
parameters.append(
ParameterNode(
name=param.name,
annotation=_empty if param.annotation is inspect._empty else str(param.annotation),
annotation=_empty
if param.annotation is inspect._empty
else str(param.annotation),
kind=param.kind.name,
default=_empty if param.default is inspect._empty else str(param.default),
default=_empty
if param.default is inspect._empty
else str(param.default),
)
)
assert isinstance(kind, str)
Expand Down
2 changes: 1 addition & 1 deletion papyri/tests/test_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,4 @@ def test_self():
},
],
}
assert g.data["papyri"].to_dict()["signature"] == None
assert g.data["papyri"].to_dict()["signature"] is None

0 comments on commit b181267

Please sign in to comment.