Skip to content

Commit

Permalink
Remove some "pragma: no cover"
Browse files Browse the repository at this point in the history
  • Loading branch information
Fatal1ty committed Jan 27, 2024
1 parent 9117d27 commit f68290a
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 56 deletions.
6 changes: 2 additions & 4 deletions mashumaro/codecs/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ def __init__(
code_builder.add_decode_method(shape_type, self, pre_decoder_func)

@final
def decode(self, data: Any) -> T: # pragma: no cover
...
def decode(self, data: Any) -> T: ...


class BasicEncoder(Generic[T]):
Expand Down Expand Up @@ -85,8 +84,7 @@ def __init__(
code_builder.add_encode_method(shape_type, self, post_encoder_func)

@final
def encode(self, obj: T) -> Any: # pragma: no cover
...
def encode(self, obj: T) -> Any: ...


def decode(data: Any, shape_type: Union[Type[T], Any]) -> T:
Expand Down
6 changes: 2 additions & 4 deletions mashumaro/codecs/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ def __init__(
code_builder.add_decode_method(shape_type, self, pre_decoder_func)

@final
def decode(self, data: EncodedData) -> T: # pragma: no cover
...
def decode(self, data: EncodedData) -> T: ...


class JSONEncoder(Generic[T]):
Expand Down Expand Up @@ -87,8 +86,7 @@ def __init__(
code_builder.add_encode_method(shape_type, self, post_encoder_func)

@final
def encode(self, obj: T) -> str: # pragma: no cover
...
def encode(self, obj: T) -> str: ...


def json_decode(
Expand Down
6 changes: 2 additions & 4 deletions mashumaro/codecs/msgpack.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ def __init__(
code_builder.add_decode_method(shape_type, self, pre_decoder_func)

@final
def decode(self, data: EncodedData) -> T: # pragma: no cover
...
def decode(self, data: EncodedData) -> T: ...


class MessagePackEncoder(Generic[T]):
Expand Down Expand Up @@ -108,8 +107,7 @@ def __init__(
code_builder.add_encode_method(shape_type, self, post_encoder_func)

@final
def encode(self, obj: T) -> EncodedData: # pragma: no cover
...
def encode(self, obj: T) -> EncodedData: ...


def msgpack_decode(data: EncodedData, shape_type: Union[Type[T], Any]) -> T:
Expand Down
6 changes: 2 additions & 4 deletions mashumaro/codecs/orjson.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ def __init__(
code_builder.add_decode_method(shape_type, self, orjson.loads)

@final
def decode(self, data: EncodedData) -> T: # pragma: no cover
...
def decode(self, data: EncodedData) -> T: ...


class ORJSONEncoder(Generic[T]):
Expand Down Expand Up @@ -90,8 +89,7 @@ def __init__(
code_builder.add_encode_method(shape_type, self, orjson.dumps)

@final
def encode(self, obj: T) -> bytes: # pragma: no cover
...
def encode(self, obj: T) -> bytes: ...


def json_decode(data: EncodedData, shape_type: Type[T]) -> T:
Expand Down
6 changes: 2 additions & 4 deletions mashumaro/codecs/toml.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ def __init__(
code_builder.add_decode_method(shape_type, self, tomllib.loads)

@final
def decode(self, data: EncodedData) -> T: # pragma: no cover
...
def decode(self, data: EncodedData) -> T: ...


class TOMLEncoder(Generic[T]):
Expand Down Expand Up @@ -95,8 +94,7 @@ def __init__(
code_builder.add_encode_method(shape_type, self, tomli_w.dumps)

@final
def encode(self, obj: T) -> bytes: # pragma: no cover
...
def encode(self, obj: T) -> bytes: ...


def toml_decode(data: EncodedData, shape_type: Type[T]) -> T:
Expand Down
6 changes: 2 additions & 4 deletions mashumaro/codecs/yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ def __init__(
code_builder.add_decode_method(shape_type, self, pre_decoder_func)

@final
def decode(self, data: EncodedData) -> T: # pragma: no cover
...
def decode(self, data: EncodedData) -> T: ...


class YAMLEncoder(Generic[T]):
Expand Down Expand Up @@ -104,8 +103,7 @@ def __init__(
code_builder.add_encode_method(shape_type, self, post_encoder_func)

@final
def encode(self, obj: T) -> EncodedData: # pragma: no cover
...
def encode(self, obj: T) -> EncodedData: ...


def yaml_decode(data: EncodedData, shape_type: Union[Type[T], Any]) -> T:
Expand Down
10 changes: 6 additions & 4 deletions tests/test_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ class DataClass(DataClassDictMixin):
x: int

@no_type_check
def __pre_deserialize__(self, d: Dict[Any, Any]) -> Dict[Any, Any]:
pass # pragma: no cover
def __pre_deserialize__(
self, d: Dict[Any, Any]
) -> Dict[Any, Any]: ...


def test_bad_post_deserialize_hook():
Expand All @@ -73,8 +74,9 @@ class DataClass(DataClassDictMixin):
x: int

@no_type_check
def __post_deserialize__(self, obj: "DataClass") -> "DataClass":
pass # pragma: no cover
def __post_deserialize__(
self, obj: "DataClass"
) -> "DataClass": ...


def test_pre_deserialize_hook():
Expand Down
20 changes: 6 additions & 14 deletions tests/test_jsonschema/test_jsonschema_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,21 +515,13 @@ class Config:


def test_jsonschema_for_named_tuple_with_overridden_serialization_method():
class MySerializationStrategy(SerializationStrategy): # pragma: no cover
def serialize(self, value: Any) -> MyNamedTuple:
pass
class MySerializationStrategy(SerializationStrategy):
def serialize(self, value: Any) -> MyNamedTuple: ...
def deserialize(self, value: Any) -> Any: ...

def deserialize(self, value: Any) -> Any:
pass

class MyAnySerializationStrategy(
SerializationStrategy
): # pragma: no cover
def serialize(self, value: Any) -> Any:
pass

def deserialize(self, value: Any) -> Any:
pass
class MyAnySerializationStrategy(SerializationStrategy):
def serialize(self, value: Any) -> Any: ...
def deserialize(self, value: Any) -> Any: ...

@dataclass
class DataClassA:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ class MyTypedDict(TypedDict):
),
)
def test_jsonschema_generation_for_forward_refs():
def foo(x: int, y: MyTypedDict):
pass
def foo(x: int, y: MyTypedDict): ...

x_type = get_function_arg_annotation(foo, "x")
assert isinstance(x_type, ForwardRef)
Expand Down
18 changes: 6 additions & 12 deletions tests/test_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,19 +116,15 @@ class DataClass(DataClassDictMixin):

def test_get_class_that_defines_method():
class A:
def foo(self):
pass # pragma: no cover
def foo(self): ...

@classmethod
def bar(cls):
pass # pragma: no cover
def bar(cls): ...

def foobar(self):
pass # pragma: no cover
def foobar(self): ...

class B(A):
def foobar(self):
pass # pragma: no cover
def foobar(self): ...

assert get_class_that_defines_method("foo", B) == A
assert get_class_that_defines_method("bar", B) == A
Expand Down Expand Up @@ -716,8 +712,7 @@ def test_ensure_mapping_key_type_hashable():


def test_get_function_arg_annotation():
def foo(x: int, y: Dialect) -> None:
pass # pragma: no cover
def foo(x: int, y: Dialect) -> None: ...

assert get_function_arg_annotation(foo, "x") == int
assert get_function_arg_annotation(foo, "y") == Dialect
Expand All @@ -730,8 +725,7 @@ def foo(x: int, y: Dialect) -> None:


def test_get_function_return_annotation():
def foo(x: int, y: Dialect) -> Dialect:
pass # pragma: no cover
def foo(x: int, y: Dialect) -> Dialect: ...

assert get_function_return_annotation(foo) == Dialect

Expand Down

0 comments on commit f68290a

Please sign in to comment.