From 1beb1e31817d8c6b0b0e561ca62087eb28444c1b Mon Sep 17 00:00:00 2001 From: Aaron Miller Date: Tue, 23 Dec 2025 19:02:55 -0800 Subject: [PATCH] Convert skymarshal templates from py2 to py3 style annotations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update skymarshal Python code generation templates to use Python 3-style inline type annotations instead of Python 2-style comment annotations. Changes: - Update python_enum.py.template: convert all method signatures from `# type: (args) -> return` comments to inline `(args: T) -> R` syntax - Update python_struct.py.template: remove quotes from forward-reference return types (e.g., `-> "Name"` becomes `-> Name`) - Add `from __future__ import annotations` to wrapper templates (python_enum_default_wrapper.py.template and python_struct_default_wrapper.py.template) to enable PEP 563 postponed annotation evaluation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 Topic: skymarshal-py3-annotations --- .../lcmtypes/codegen_cpp_test/_constants_t.py | 12 +++--- .../lcmtypes/codegen_cpp_test/_states_t.py | 12 +++--- .../codegen_cpp_test/_values_vec_t.py | 12 +++--- .../lcmtypes/codegen_test/_my_dataclass_t.py | 12 +++--- .../_constants_t.py | 12 +++--- .../_states_t.py | 12 +++--- .../_values_vec_t.py | 12 +++--- .../_inputs_constants_t.py | 12 +++--- .../_inputs_states_t.py | 12 +++--- .../codegen_multi_function_test/_inputs_t.py | 12 +++--- .../_outputs_1_t.py | 12 +++--- .../_outputs_2_t.py | 12 +++--- .../_values_vec_t.py | 12 +++--- .../codegen_python_test/_constants_t.py | 12 +++--- .../lcmtypes/codegen_python_test/_states_t.py | 12 +++--- .../codegen_python_test/_values_vec_t.py | 12 +++--- .../python/lcmtypes/sym/_d_out_t.py | 12 +++--- .../python/lcmtypes/sym/_d_t.py | 12 +++--- .../lcmtypes/codegen_cpp_test/_constants_t.py | 12 +++--- .../lcmtypes/codegen_cpp_test/_states_t.py | 12 +++--- .../codegen_cpp_test/_values_vec_t.py | 12 +++--- .../lcmtypes/codegen_test/_my_dataclass_t.py | 12 +++--- .../_constants_t.py | 12 +++--- .../_states_t.py | 12 +++--- .../_values_vec_t.py | 12 +++--- .../_inputs_constants_t.py | 12 +++--- .../_inputs_states_t.py | 12 +++--- .../codegen_multi_function_test/_inputs_t.py | 12 +++--- .../_outputs_1_t.py | 12 +++--- .../_outputs_2_t.py | 12 +++--- .../_values_vec_t.py | 12 +++--- .../codegen_python_test/_constants_t.py | 12 +++--- .../lcmtypes/codegen_python_test/_states_t.py | 12 +++--- .../codegen_python_test/_values_vec_t.py | 12 +++--- .../python/lcmtypes/sym/_d_out_t.py | 12 +++--- .../python/lcmtypes/sym/_d_t.py | 12 +++--- .../templates/python_enum.py.template | 38 +++++++------------ .../python_enum_default_wrapper.py.template | 2 + .../templates/python_struct.py.template | 10 ++--- .../python_struct_default_wrapper.py.template | 2 + 40 files changed, 275 insertions(+), 209 deletions(-) diff --git a/test/symforce_function_codegen_test_data/symengine/codegen_cpp_test_data/python/lcmtypes/codegen_cpp_test/_constants_t.py b/test/symforce_function_codegen_test_data/symengine/codegen_cpp_test_data/python/lcmtypes/codegen_cpp_test/_constants_t.py index b52467dae..958e6591e 100644 --- a/test/symforce_function_codegen_test_data/symengine/codegen_cpp_test_data/python/lcmtypes/codegen_cpp_test/_constants_t.py +++ b/test/symforce_function_codegen_test_data/symengine/codegen_cpp_test_data/python/lcmtypes/codegen_cpp_test/_constants_t.py @@ -4,6 +4,8 @@ # isort: off # mypy: disallow-untyped-defs +from __future__ import annotations + import copy import typing as T @@ -26,7 +28,7 @@ def __init__( @staticmethod def from_all_fields( epsilon: float, - ) -> "constants_t": + ) -> constants_t: return constants_t( epsilon=epsilon, ) @@ -40,7 +42,7 @@ def _skytype_meta() -> T.Dict[str, str]: ) @classmethod - def _default(cls) -> "constants_t": + def _default(cls) -> constants_t: return cls() def __repr__(self) -> str: @@ -66,7 +68,7 @@ def _encode_one(self, buf: T.BinaryIO) -> None: buf.write(constants_t._CACHED_STRUCT_0.pack(self.epsilon)) @staticmethod - def decode(data: T.Union[bytes, T.BinaryIO]) -> "constants_t": + def decode(data: T.Union[bytes, T.BinaryIO]) -> constants_t: # NOTE(eric): This function can technically accept either a BinaryIO or # anything that supports the C++ Buffer Protocol, # which is unspecifiable in type hints. @@ -82,7 +84,7 @@ def decode(data: T.Union[bytes, T.BinaryIO]) -> "constants_t": return constants_t._decode_one(buf) @staticmethod - def _decode_one(buf: T.BinaryIO) -> "constants_t": + def _decode_one(buf: T.BinaryIO) -> constants_t: self = constants_t(_skip_initialize=True) self.epsilon = constants_t._CACHED_STRUCT_0.unpack(buf.read(8))[0] return self @@ -102,7 +104,7 @@ def _get_packed_fingerprint() -> bytes: constants_t._packed_fingerprint = struct.pack(">Q", constants_t._get_hash_recursive([])) return constants_t._packed_fingerprint - def deepcopy(self, **kwargs: T.Any) -> "constants_t": + def deepcopy(self, **kwargs: T.Any) -> constants_t: """ Deep copy of this LCM type diff --git a/test/symforce_function_codegen_test_data/symengine/codegen_cpp_test_data/python/lcmtypes/codegen_cpp_test/_states_t.py b/test/symforce_function_codegen_test_data/symengine/codegen_cpp_test_data/python/lcmtypes/codegen_cpp_test/_states_t.py index e0f7f1a5a..17a06c86b 100644 --- a/test/symforce_function_codegen_test_data/symengine/codegen_cpp_test_data/python/lcmtypes/codegen_cpp_test/_states_t.py +++ b/test/symforce_function_codegen_test_data/symengine/codegen_cpp_test_data/python/lcmtypes/codegen_cpp_test/_states_t.py @@ -4,6 +4,8 @@ # isort: off # mypy: disallow-untyped-defs +from __future__ import annotations + import copy import typing as T @@ -27,7 +29,7 @@ def __init__( @staticmethod def from_all_fields( p: Vector2d, - ) -> "states_t": + ) -> states_t: return states_t( p=p, ) @@ -41,7 +43,7 @@ def _skytype_meta() -> T.Dict[str, str]: ) @classmethod - def _default(cls) -> "states_t": + def _default(cls) -> states_t: return cls() def __repr__(self) -> str: @@ -71,7 +73,7 @@ def _encode_one(self, buf: T.BinaryIO) -> None: self.p._encode_one(buf) @staticmethod - def decode(data: T.Union[bytes, T.BinaryIO]) -> "states_t": + def decode(data: T.Union[bytes, T.BinaryIO]) -> states_t: # NOTE(eric): This function can technically accept either a BinaryIO or # anything that supports the C++ Buffer Protocol, # which is unspecifiable in type hints. @@ -87,7 +89,7 @@ def decode(data: T.Union[bytes, T.BinaryIO]) -> "states_t": return states_t._decode_one(buf) @staticmethod - def _decode_one(buf: T.BinaryIO) -> "states_t": + def _decode_one(buf: T.BinaryIO) -> states_t: self = states_t(_skip_initialize=True) self.p = Vector2d._decode_one(buf) return self @@ -108,7 +110,7 @@ def _get_packed_fingerprint() -> bytes: states_t._packed_fingerprint = struct.pack(">Q", states_t._get_hash_recursive([])) return states_t._packed_fingerprint - def deepcopy(self, **kwargs: T.Any) -> "states_t": + def deepcopy(self, **kwargs: T.Any) -> states_t: """ Deep copy of this LCM type diff --git a/test/symforce_function_codegen_test_data/symengine/codegen_cpp_test_data/python/lcmtypes/codegen_cpp_test/_values_vec_t.py b/test/symforce_function_codegen_test_data/symengine/codegen_cpp_test_data/python/lcmtypes/codegen_cpp_test/_values_vec_t.py index 6cf7415c3..a3d742205 100644 --- a/test/symforce_function_codegen_test_data/symengine/codegen_cpp_test_data/python/lcmtypes/codegen_cpp_test/_values_vec_t.py +++ b/test/symforce_function_codegen_test_data/symengine/codegen_cpp_test_data/python/lcmtypes/codegen_cpp_test/_values_vec_t.py @@ -4,6 +4,8 @@ # isort: off # mypy: disallow-untyped-defs +from __future__ import annotations + import copy import typing as T @@ -42,7 +44,7 @@ def from_all_fields( rot_vec: T.List[Vector4d], scalar_vec: T.List[float], list_of_lists: T.List[T.List[Vector4d]], - ) -> "values_vec_t": + ) -> values_vec_t: return values_vec_t( x=x, y=y, @@ -61,7 +63,7 @@ def _skytype_meta() -> T.Dict[str, str]: ) @classmethod - def _default(cls) -> "values_vec_t": + def _default(cls) -> values_vec_t: return cls() def __repr__(self) -> str: @@ -111,7 +113,7 @@ def _encode_one(self, buf: T.BinaryIO) -> None: self.list_of_lists[i0][i1]._encode_one(buf) @staticmethod - def decode(data: T.Union[bytes, T.BinaryIO]) -> "values_vec_t": + def decode(data: T.Union[bytes, T.BinaryIO]) -> values_vec_t: # NOTE(eric): This function can technically accept either a BinaryIO or # anything that supports the C++ Buffer Protocol, # which is unspecifiable in type hints. @@ -127,7 +129,7 @@ def decode(data: T.Union[bytes, T.BinaryIO]) -> "values_vec_t": return values_vec_t._decode_one(buf) @staticmethod - def _decode_one(buf: T.BinaryIO) -> "values_vec_t": + def _decode_one(buf: T.BinaryIO) -> values_vec_t: self = values_vec_t(_skip_initialize=True) self.x, self.y = values_vec_t._CACHED_STRUCT_0.unpack(buf.read(16)) self.rot = Vector4d._decode_one(buf) @@ -158,7 +160,7 @@ def _get_packed_fingerprint() -> bytes: values_vec_t._packed_fingerprint = struct.pack(">Q", values_vec_t._get_hash_recursive([])) return values_vec_t._packed_fingerprint - def deepcopy(self, **kwargs: T.Any) -> "values_vec_t": + def deepcopy(self, **kwargs: T.Any) -> values_vec_t: """ Deep copy of this LCM type diff --git a/test/symforce_function_codegen_test_data/symengine/codegen_dataclass_in_values_test_data/python/lcmtypes/codegen_test/_my_dataclass_t.py b/test/symforce_function_codegen_test_data/symengine/codegen_dataclass_in_values_test_data/python/lcmtypes/codegen_test/_my_dataclass_t.py index 8f10dae5b..186493add 100644 --- a/test/symforce_function_codegen_test_data/symengine/codegen_dataclass_in_values_test_data/python/lcmtypes/codegen_test/_my_dataclass_t.py +++ b/test/symforce_function_codegen_test_data/symengine/codegen_dataclass_in_values_test_data/python/lcmtypes/codegen_test/_my_dataclass_t.py @@ -4,6 +4,8 @@ # isort: off # mypy: disallow-untyped-defs +from __future__ import annotations + import copy import typing as T @@ -27,7 +29,7 @@ def __init__( @staticmethod def from_all_fields( rot: Vector4d, - ) -> "my_dataclass_t": + ) -> my_dataclass_t: return my_dataclass_t( rot=rot, ) @@ -41,7 +43,7 @@ def _skytype_meta() -> T.Dict[str, str]: ) @classmethod - def _default(cls) -> "my_dataclass_t": + def _default(cls) -> my_dataclass_t: return cls() def __repr__(self) -> str: @@ -71,7 +73,7 @@ def _encode_one(self, buf: T.BinaryIO) -> None: self.rot._encode_one(buf) @staticmethod - def decode(data: T.Union[bytes, T.BinaryIO]) -> "my_dataclass_t": + def decode(data: T.Union[bytes, T.BinaryIO]) -> my_dataclass_t: # NOTE(eric): This function can technically accept either a BinaryIO or # anything that supports the C++ Buffer Protocol, # which is unspecifiable in type hints. @@ -87,7 +89,7 @@ def decode(data: T.Union[bytes, T.BinaryIO]) -> "my_dataclass_t": return my_dataclass_t._decode_one(buf) @staticmethod - def _decode_one(buf: T.BinaryIO) -> "my_dataclass_t": + def _decode_one(buf: T.BinaryIO) -> my_dataclass_t: self = my_dataclass_t(_skip_initialize=True) self.rot = Vector4d._decode_one(buf) return self @@ -108,7 +110,7 @@ def _get_packed_fingerprint() -> bytes: my_dataclass_t._packed_fingerprint = struct.pack(">Q", my_dataclass_t._get_hash_recursive([])) return my_dataclass_t._packed_fingerprint - def deepcopy(self, **kwargs: T.Any) -> "my_dataclass_t": + def deepcopy(self, **kwargs: T.Any) -> my_dataclass_t: """ Deep copy of this LCM type diff --git a/test/symforce_function_codegen_test_data/symengine/codegen_explicit_template_instantiation_test_data/python/lcmtypes/codegen_explicit_template_instantiation_test/_constants_t.py b/test/symforce_function_codegen_test_data/symengine/codegen_explicit_template_instantiation_test_data/python/lcmtypes/codegen_explicit_template_instantiation_test/_constants_t.py index c8c4446c2..2cbf082c9 100644 --- a/test/symforce_function_codegen_test_data/symengine/codegen_explicit_template_instantiation_test_data/python/lcmtypes/codegen_explicit_template_instantiation_test/_constants_t.py +++ b/test/symforce_function_codegen_test_data/symengine/codegen_explicit_template_instantiation_test_data/python/lcmtypes/codegen_explicit_template_instantiation_test/_constants_t.py @@ -4,6 +4,8 @@ # isort: off # mypy: disallow-untyped-defs +from __future__ import annotations + import copy import typing as T @@ -26,7 +28,7 @@ def __init__( @staticmethod def from_all_fields( epsilon: float, - ) -> "constants_t": + ) -> constants_t: return constants_t( epsilon=epsilon, ) @@ -40,7 +42,7 @@ def _skytype_meta() -> T.Dict[str, str]: ) @classmethod - def _default(cls) -> "constants_t": + def _default(cls) -> constants_t: return cls() def __repr__(self) -> str: @@ -66,7 +68,7 @@ def _encode_one(self, buf: T.BinaryIO) -> None: buf.write(constants_t._CACHED_STRUCT_0.pack(self.epsilon)) @staticmethod - def decode(data: T.Union[bytes, T.BinaryIO]) -> "constants_t": + def decode(data: T.Union[bytes, T.BinaryIO]) -> constants_t: # NOTE(eric): This function can technically accept either a BinaryIO or # anything that supports the C++ Buffer Protocol, # which is unspecifiable in type hints. @@ -82,7 +84,7 @@ def decode(data: T.Union[bytes, T.BinaryIO]) -> "constants_t": return constants_t._decode_one(buf) @staticmethod - def _decode_one(buf: T.BinaryIO) -> "constants_t": + def _decode_one(buf: T.BinaryIO) -> constants_t: self = constants_t(_skip_initialize=True) self.epsilon = constants_t._CACHED_STRUCT_0.unpack(buf.read(8))[0] return self @@ -102,7 +104,7 @@ def _get_packed_fingerprint() -> bytes: constants_t._packed_fingerprint = struct.pack(">Q", constants_t._get_hash_recursive([])) return constants_t._packed_fingerprint - def deepcopy(self, **kwargs: T.Any) -> "constants_t": + def deepcopy(self, **kwargs: T.Any) -> constants_t: """ Deep copy of this LCM type diff --git a/test/symforce_function_codegen_test_data/symengine/codegen_explicit_template_instantiation_test_data/python/lcmtypes/codegen_explicit_template_instantiation_test/_states_t.py b/test/symforce_function_codegen_test_data/symengine/codegen_explicit_template_instantiation_test_data/python/lcmtypes/codegen_explicit_template_instantiation_test/_states_t.py index 04c083b35..f1848f835 100644 --- a/test/symforce_function_codegen_test_data/symengine/codegen_explicit_template_instantiation_test_data/python/lcmtypes/codegen_explicit_template_instantiation_test/_states_t.py +++ b/test/symforce_function_codegen_test_data/symengine/codegen_explicit_template_instantiation_test_data/python/lcmtypes/codegen_explicit_template_instantiation_test/_states_t.py @@ -4,6 +4,8 @@ # isort: off # mypy: disallow-untyped-defs +from __future__ import annotations + import copy import typing as T @@ -27,7 +29,7 @@ def __init__( @staticmethod def from_all_fields( p: Vector2d, - ) -> "states_t": + ) -> states_t: return states_t( p=p, ) @@ -41,7 +43,7 @@ def _skytype_meta() -> T.Dict[str, str]: ) @classmethod - def _default(cls) -> "states_t": + def _default(cls) -> states_t: return cls() def __repr__(self) -> str: @@ -71,7 +73,7 @@ def _encode_one(self, buf: T.BinaryIO) -> None: self.p._encode_one(buf) @staticmethod - def decode(data: T.Union[bytes, T.BinaryIO]) -> "states_t": + def decode(data: T.Union[bytes, T.BinaryIO]) -> states_t: # NOTE(eric): This function can technically accept either a BinaryIO or # anything that supports the C++ Buffer Protocol, # which is unspecifiable in type hints. @@ -87,7 +89,7 @@ def decode(data: T.Union[bytes, T.BinaryIO]) -> "states_t": return states_t._decode_one(buf) @staticmethod - def _decode_one(buf: T.BinaryIO) -> "states_t": + def _decode_one(buf: T.BinaryIO) -> states_t: self = states_t(_skip_initialize=True) self.p = Vector2d._decode_one(buf) return self @@ -108,7 +110,7 @@ def _get_packed_fingerprint() -> bytes: states_t._packed_fingerprint = struct.pack(">Q", states_t._get_hash_recursive([])) return states_t._packed_fingerprint - def deepcopy(self, **kwargs: T.Any) -> "states_t": + def deepcopy(self, **kwargs: T.Any) -> states_t: """ Deep copy of this LCM type diff --git a/test/symforce_function_codegen_test_data/symengine/codegen_explicit_template_instantiation_test_data/python/lcmtypes/codegen_explicit_template_instantiation_test/_values_vec_t.py b/test/symforce_function_codegen_test_data/symengine/codegen_explicit_template_instantiation_test_data/python/lcmtypes/codegen_explicit_template_instantiation_test/_values_vec_t.py index 80ccbc352..2391fea10 100644 --- a/test/symforce_function_codegen_test_data/symengine/codegen_explicit_template_instantiation_test_data/python/lcmtypes/codegen_explicit_template_instantiation_test/_values_vec_t.py +++ b/test/symforce_function_codegen_test_data/symengine/codegen_explicit_template_instantiation_test_data/python/lcmtypes/codegen_explicit_template_instantiation_test/_values_vec_t.py @@ -4,6 +4,8 @@ # isort: off # mypy: disallow-untyped-defs +from __future__ import annotations + import copy import typing as T @@ -42,7 +44,7 @@ def from_all_fields( rot_vec: T.List[Vector4d], scalar_vec: T.List[float], list_of_lists: T.List[T.List[Vector4d]], - ) -> "values_vec_t": + ) -> values_vec_t: return values_vec_t( x=x, y=y, @@ -61,7 +63,7 @@ def _skytype_meta() -> T.Dict[str, str]: ) @classmethod - def _default(cls) -> "values_vec_t": + def _default(cls) -> values_vec_t: return cls() def __repr__(self) -> str: @@ -111,7 +113,7 @@ def _encode_one(self, buf: T.BinaryIO) -> None: self.list_of_lists[i0][i1]._encode_one(buf) @staticmethod - def decode(data: T.Union[bytes, T.BinaryIO]) -> "values_vec_t": + def decode(data: T.Union[bytes, T.BinaryIO]) -> values_vec_t: # NOTE(eric): This function can technically accept either a BinaryIO or # anything that supports the C++ Buffer Protocol, # which is unspecifiable in type hints. @@ -127,7 +129,7 @@ def decode(data: T.Union[bytes, T.BinaryIO]) -> "values_vec_t": return values_vec_t._decode_one(buf) @staticmethod - def _decode_one(buf: T.BinaryIO) -> "values_vec_t": + def _decode_one(buf: T.BinaryIO) -> values_vec_t: self = values_vec_t(_skip_initialize=True) self.x, self.y = values_vec_t._CACHED_STRUCT_0.unpack(buf.read(16)) self.rot = Vector4d._decode_one(buf) @@ -158,7 +160,7 @@ def _get_packed_fingerprint() -> bytes: values_vec_t._packed_fingerprint = struct.pack(">Q", values_vec_t._get_hash_recursive([])) return values_vec_t._packed_fingerprint - def deepcopy(self, **kwargs: T.Any) -> "values_vec_t": + def deepcopy(self, **kwargs: T.Any) -> values_vec_t: """ Deep copy of this LCM type diff --git a/test/symforce_function_codegen_test_data/symengine/codegen_multi_function_test_data/python/lcmtypes/codegen_multi_function_test/_inputs_constants_t.py b/test/symforce_function_codegen_test_data/symengine/codegen_multi_function_test_data/python/lcmtypes/codegen_multi_function_test/_inputs_constants_t.py index 66310104b..5bafc7b28 100644 --- a/test/symforce_function_codegen_test_data/symengine/codegen_multi_function_test_data/python/lcmtypes/codegen_multi_function_test/_inputs_constants_t.py +++ b/test/symforce_function_codegen_test_data/symengine/codegen_multi_function_test_data/python/lcmtypes/codegen_multi_function_test/_inputs_constants_t.py @@ -4,6 +4,8 @@ # isort: off # mypy: disallow-untyped-defs +from __future__ import annotations + import copy import typing as T @@ -26,7 +28,7 @@ def __init__( @staticmethod def from_all_fields( epsilon: float, - ) -> "inputs_constants_t": + ) -> inputs_constants_t: return inputs_constants_t( epsilon=epsilon, ) @@ -40,7 +42,7 @@ def _skytype_meta() -> T.Dict[str, str]: ) @classmethod - def _default(cls) -> "inputs_constants_t": + def _default(cls) -> inputs_constants_t: return cls() def __repr__(self) -> str: @@ -66,7 +68,7 @@ def _encode_one(self, buf: T.BinaryIO) -> None: buf.write(inputs_constants_t._CACHED_STRUCT_0.pack(self.epsilon)) @staticmethod - def decode(data: T.Union[bytes, T.BinaryIO]) -> "inputs_constants_t": + def decode(data: T.Union[bytes, T.BinaryIO]) -> inputs_constants_t: # NOTE(eric): This function can technically accept either a BinaryIO or # anything that supports the C++ Buffer Protocol, # which is unspecifiable in type hints. @@ -82,7 +84,7 @@ def decode(data: T.Union[bytes, T.BinaryIO]) -> "inputs_constants_t": return inputs_constants_t._decode_one(buf) @staticmethod - def _decode_one(buf: T.BinaryIO) -> "inputs_constants_t": + def _decode_one(buf: T.BinaryIO) -> inputs_constants_t: self = inputs_constants_t(_skip_initialize=True) self.epsilon = inputs_constants_t._CACHED_STRUCT_0.unpack(buf.read(8))[0] return self @@ -102,7 +104,7 @@ def _get_packed_fingerprint() -> bytes: inputs_constants_t._packed_fingerprint = struct.pack(">Q", inputs_constants_t._get_hash_recursive([])) return inputs_constants_t._packed_fingerprint - def deepcopy(self, **kwargs: T.Any) -> "inputs_constants_t": + def deepcopy(self, **kwargs: T.Any) -> inputs_constants_t: """ Deep copy of this LCM type diff --git a/test/symforce_function_codegen_test_data/symengine/codegen_multi_function_test_data/python/lcmtypes/codegen_multi_function_test/_inputs_states_t.py b/test/symforce_function_codegen_test_data/symengine/codegen_multi_function_test_data/python/lcmtypes/codegen_multi_function_test/_inputs_states_t.py index 44b28b2ef..80a382284 100644 --- a/test/symforce_function_codegen_test_data/symengine/codegen_multi_function_test_data/python/lcmtypes/codegen_multi_function_test/_inputs_states_t.py +++ b/test/symforce_function_codegen_test_data/symengine/codegen_multi_function_test_data/python/lcmtypes/codegen_multi_function_test/_inputs_states_t.py @@ -4,6 +4,8 @@ # isort: off # mypy: disallow-untyped-defs +from __future__ import annotations + import copy import typing as T @@ -27,7 +29,7 @@ def __init__( @staticmethod def from_all_fields( p: Vector2d, - ) -> "inputs_states_t": + ) -> inputs_states_t: return inputs_states_t( p=p, ) @@ -41,7 +43,7 @@ def _skytype_meta() -> T.Dict[str, str]: ) @classmethod - def _default(cls) -> "inputs_states_t": + def _default(cls) -> inputs_states_t: return cls() def __repr__(self) -> str: @@ -71,7 +73,7 @@ def _encode_one(self, buf: T.BinaryIO) -> None: self.p._encode_one(buf) @staticmethod - def decode(data: T.Union[bytes, T.BinaryIO]) -> "inputs_states_t": + def decode(data: T.Union[bytes, T.BinaryIO]) -> inputs_states_t: # NOTE(eric): This function can technically accept either a BinaryIO or # anything that supports the C++ Buffer Protocol, # which is unspecifiable in type hints. @@ -87,7 +89,7 @@ def decode(data: T.Union[bytes, T.BinaryIO]) -> "inputs_states_t": return inputs_states_t._decode_one(buf) @staticmethod - def _decode_one(buf: T.BinaryIO) -> "inputs_states_t": + def _decode_one(buf: T.BinaryIO) -> inputs_states_t: self = inputs_states_t(_skip_initialize=True) self.p = Vector2d._decode_one(buf) return self @@ -108,7 +110,7 @@ def _get_packed_fingerprint() -> bytes: inputs_states_t._packed_fingerprint = struct.pack(">Q", inputs_states_t._get_hash_recursive([])) return inputs_states_t._packed_fingerprint - def deepcopy(self, **kwargs: T.Any) -> "inputs_states_t": + def deepcopy(self, **kwargs: T.Any) -> inputs_states_t: """ Deep copy of this LCM type diff --git a/test/symforce_function_codegen_test_data/symengine/codegen_multi_function_test_data/python/lcmtypes/codegen_multi_function_test/_inputs_t.py b/test/symforce_function_codegen_test_data/symengine/codegen_multi_function_test_data/python/lcmtypes/codegen_multi_function_test/_inputs_t.py index e9ac7b16a..8daa0acb8 100644 --- a/test/symforce_function_codegen_test_data/symengine/codegen_multi_function_test_data/python/lcmtypes/codegen_multi_function_test/_inputs_t.py +++ b/test/symforce_function_codegen_test_data/symengine/codegen_multi_function_test_data/python/lcmtypes/codegen_multi_function_test/_inputs_t.py @@ -4,6 +4,8 @@ # isort: off # mypy: disallow-untyped-defs +from __future__ import annotations + import copy import typing as T @@ -65,7 +67,7 @@ def from_all_fields( big_matrix: MatrixXd, small_matrix: Matrix4d, states: inputs_states_t, - ) -> "inputs_t": + ) -> inputs_t: return inputs_t( x=x, y=y, @@ -90,7 +92,7 @@ def _skytype_meta() -> T.Dict[str, str]: ) @classmethod - def _default(cls) -> "inputs_t": + def _default(cls) -> inputs_t: return cls() def __repr__(self) -> str: @@ -179,7 +181,7 @@ def _encode_one(self, buf: T.BinaryIO) -> None: self.states._encode_one(buf) @staticmethod - def decode(data: T.Union[bytes, T.BinaryIO]) -> "inputs_t": + def decode(data: T.Union[bytes, T.BinaryIO]) -> inputs_t: # NOTE(eric): This function can technically accept either a BinaryIO or # anything that supports the C++ Buffer Protocol, # which is unspecifiable in type hints. @@ -195,7 +197,7 @@ def decode(data: T.Union[bytes, T.BinaryIO]) -> "inputs_t": return inputs_t._decode_one(buf) @staticmethod - def _decode_one(buf: T.BinaryIO) -> "inputs_t": + def _decode_one(buf: T.BinaryIO) -> inputs_t: self = inputs_t(_skip_initialize=True) self.x, self.y = inputs_t._CACHED_STRUCT_0.unpack(buf.read(16)) self.rot = Vector4d._decode_one(buf) @@ -238,7 +240,7 @@ def _get_packed_fingerprint() -> bytes: inputs_t._packed_fingerprint = struct.pack(">Q", inputs_t._get_hash_recursive([])) return inputs_t._packed_fingerprint - def deepcopy(self, **kwargs: T.Any) -> "inputs_t": + def deepcopy(self, **kwargs: T.Any) -> inputs_t: """ Deep copy of this LCM type diff --git a/test/symforce_function_codegen_test_data/symengine/codegen_multi_function_test_data/python/lcmtypes/codegen_multi_function_test/_outputs_1_t.py b/test/symforce_function_codegen_test_data/symengine/codegen_multi_function_test_data/python/lcmtypes/codegen_multi_function_test/_outputs_1_t.py index 37e882e3a..d128924a7 100644 --- a/test/symforce_function_codegen_test_data/symengine/codegen_multi_function_test_data/python/lcmtypes/codegen_multi_function_test/_outputs_1_t.py +++ b/test/symforce_function_codegen_test_data/symengine/codegen_multi_function_test_data/python/lcmtypes/codegen_multi_function_test/_outputs_1_t.py @@ -4,6 +4,8 @@ # isort: off # mypy: disallow-untyped-defs +from __future__ import annotations + import copy import typing as T @@ -47,7 +49,7 @@ def from_all_fields( values_vec_2D_out: T.List[T.List[values_vec_t]], big_matrix_from_small_matrix: MatrixXd, small_matrix_from_big_matrix: Matrix4d, - ) -> "outputs_1_t": + ) -> outputs_1_t: return outputs_1_t( foo=foo, bar=bar, @@ -67,7 +69,7 @@ def _skytype_meta() -> T.Dict[str, str]: ) @classmethod - def _default(cls) -> "outputs_1_t": + def _default(cls) -> outputs_1_t: return cls() def __repr__(self) -> str: @@ -123,7 +125,7 @@ def _encode_one(self, buf: T.BinaryIO) -> None: self.small_matrix_from_big_matrix._encode_one(buf) @staticmethod - def decode(data: T.Union[bytes, T.BinaryIO]) -> "outputs_1_t": + def decode(data: T.Union[bytes, T.BinaryIO]) -> outputs_1_t: # NOTE(eric): This function can technically accept either a BinaryIO or # anything that supports the C++ Buffer Protocol, # which is unspecifiable in type hints. @@ -139,7 +141,7 @@ def decode(data: T.Union[bytes, T.BinaryIO]) -> "outputs_1_t": return outputs_1_t._decode_one(buf) @staticmethod - def _decode_one(buf: T.BinaryIO) -> "outputs_1_t": + def _decode_one(buf: T.BinaryIO) -> outputs_1_t: self = outputs_1_t(_skip_initialize=True) self.foo, self.bar = outputs_1_t._CACHED_STRUCT_0.unpack(buf.read(16)) self.scalar_vec_out = list(outputs_1_t._CACHED_STRUCT_1.unpack(buf.read(24))) @@ -171,7 +173,7 @@ def _get_packed_fingerprint() -> bytes: outputs_1_t._packed_fingerprint = struct.pack(">Q", outputs_1_t._get_hash_recursive([])) return outputs_1_t._packed_fingerprint - def deepcopy(self, **kwargs: T.Any) -> "outputs_1_t": + def deepcopy(self, **kwargs: T.Any) -> outputs_1_t: """ Deep copy of this LCM type diff --git a/test/symforce_function_codegen_test_data/symengine/codegen_multi_function_test_data/python/lcmtypes/codegen_multi_function_test/_outputs_2_t.py b/test/symforce_function_codegen_test_data/symengine/codegen_multi_function_test_data/python/lcmtypes/codegen_multi_function_test/_outputs_2_t.py index eb0ad1637..b6f640e20 100644 --- a/test/symforce_function_codegen_test_data/symengine/codegen_multi_function_test_data/python/lcmtypes/codegen_multi_function_test/_outputs_2_t.py +++ b/test/symforce_function_codegen_test_data/symengine/codegen_multi_function_test_data/python/lcmtypes/codegen_multi_function_test/_outputs_2_t.py @@ -4,6 +4,8 @@ # isort: off # mypy: disallow-untyped-defs +from __future__ import annotations + import copy import typing as T @@ -26,7 +28,7 @@ def __init__( @staticmethod def from_all_fields( foo: float, - ) -> "outputs_2_t": + ) -> outputs_2_t: return outputs_2_t( foo=foo, ) @@ -40,7 +42,7 @@ def _skytype_meta() -> T.Dict[str, str]: ) @classmethod - def _default(cls) -> "outputs_2_t": + def _default(cls) -> outputs_2_t: return cls() def __repr__(self) -> str: @@ -66,7 +68,7 @@ def _encode_one(self, buf: T.BinaryIO) -> None: buf.write(outputs_2_t._CACHED_STRUCT_0.pack(self.foo)) @staticmethod - def decode(data: T.Union[bytes, T.BinaryIO]) -> "outputs_2_t": + def decode(data: T.Union[bytes, T.BinaryIO]) -> outputs_2_t: # NOTE(eric): This function can technically accept either a BinaryIO or # anything that supports the C++ Buffer Protocol, # which is unspecifiable in type hints. @@ -82,7 +84,7 @@ def decode(data: T.Union[bytes, T.BinaryIO]) -> "outputs_2_t": return outputs_2_t._decode_one(buf) @staticmethod - def _decode_one(buf: T.BinaryIO) -> "outputs_2_t": + def _decode_one(buf: T.BinaryIO) -> outputs_2_t: self = outputs_2_t(_skip_initialize=True) self.foo = outputs_2_t._CACHED_STRUCT_0.unpack(buf.read(8))[0] return self @@ -102,7 +104,7 @@ def _get_packed_fingerprint() -> bytes: outputs_2_t._packed_fingerprint = struct.pack(">Q", outputs_2_t._get_hash_recursive([])) return outputs_2_t._packed_fingerprint - def deepcopy(self, **kwargs: T.Any) -> "outputs_2_t": + def deepcopy(self, **kwargs: T.Any) -> outputs_2_t: """ Deep copy of this LCM type diff --git a/test/symforce_function_codegen_test_data/symengine/codegen_multi_function_test_data/python/lcmtypes/codegen_multi_function_test/_values_vec_t.py b/test/symforce_function_codegen_test_data/symengine/codegen_multi_function_test_data/python/lcmtypes/codegen_multi_function_test/_values_vec_t.py index 87518da02..df1d62161 100644 --- a/test/symforce_function_codegen_test_data/symengine/codegen_multi_function_test_data/python/lcmtypes/codegen_multi_function_test/_values_vec_t.py +++ b/test/symforce_function_codegen_test_data/symengine/codegen_multi_function_test_data/python/lcmtypes/codegen_multi_function_test/_values_vec_t.py @@ -4,6 +4,8 @@ # isort: off # mypy: disallow-untyped-defs +from __future__ import annotations + import copy import typing as T @@ -42,7 +44,7 @@ def from_all_fields( rot_vec: T.List[Vector4d], scalar_vec: T.List[float], list_of_lists: T.List[T.List[Vector4d]], - ) -> "values_vec_t": + ) -> values_vec_t: return values_vec_t( x=x, y=y, @@ -61,7 +63,7 @@ def _skytype_meta() -> T.Dict[str, str]: ) @classmethod - def _default(cls) -> "values_vec_t": + def _default(cls) -> values_vec_t: return cls() def __repr__(self) -> str: @@ -111,7 +113,7 @@ def _encode_one(self, buf: T.BinaryIO) -> None: self.list_of_lists[i0][i1]._encode_one(buf) @staticmethod - def decode(data: T.Union[bytes, T.BinaryIO]) -> "values_vec_t": + def decode(data: T.Union[bytes, T.BinaryIO]) -> values_vec_t: # NOTE(eric): This function can technically accept either a BinaryIO or # anything that supports the C++ Buffer Protocol, # which is unspecifiable in type hints. @@ -127,7 +129,7 @@ def decode(data: T.Union[bytes, T.BinaryIO]) -> "values_vec_t": return values_vec_t._decode_one(buf) @staticmethod - def _decode_one(buf: T.BinaryIO) -> "values_vec_t": + def _decode_one(buf: T.BinaryIO) -> values_vec_t: self = values_vec_t(_skip_initialize=True) self.x, self.y = values_vec_t._CACHED_STRUCT_0.unpack(buf.read(16)) self.rot = Vector4d._decode_one(buf) @@ -158,7 +160,7 @@ def _get_packed_fingerprint() -> bytes: values_vec_t._packed_fingerprint = struct.pack(">Q", values_vec_t._get_hash_recursive([])) return values_vec_t._packed_fingerprint - def deepcopy(self, **kwargs: T.Any) -> "values_vec_t": + def deepcopy(self, **kwargs: T.Any) -> values_vec_t: """ Deep copy of this LCM type diff --git a/test/symforce_function_codegen_test_data/symengine/codegen_python_test_data/python/lcmtypes/codegen_python_test/_constants_t.py b/test/symforce_function_codegen_test_data/symengine/codegen_python_test_data/python/lcmtypes/codegen_python_test/_constants_t.py index 9bb48c1ee..d5cde170d 100644 --- a/test/symforce_function_codegen_test_data/symengine/codegen_python_test_data/python/lcmtypes/codegen_python_test/_constants_t.py +++ b/test/symforce_function_codegen_test_data/symengine/codegen_python_test_data/python/lcmtypes/codegen_python_test/_constants_t.py @@ -4,6 +4,8 @@ # isort: off # mypy: disallow-untyped-defs +from __future__ import annotations + import copy import typing as T @@ -26,7 +28,7 @@ def __init__( @staticmethod def from_all_fields( epsilon: float, - ) -> "constants_t": + ) -> constants_t: return constants_t( epsilon=epsilon, ) @@ -40,7 +42,7 @@ def _skytype_meta() -> T.Dict[str, str]: ) @classmethod - def _default(cls) -> "constants_t": + def _default(cls) -> constants_t: return cls() def __repr__(self) -> str: @@ -66,7 +68,7 @@ def _encode_one(self, buf: T.BinaryIO) -> None: buf.write(constants_t._CACHED_STRUCT_0.pack(self.epsilon)) @staticmethod - def decode(data: T.Union[bytes, T.BinaryIO]) -> "constants_t": + def decode(data: T.Union[bytes, T.BinaryIO]) -> constants_t: # NOTE(eric): This function can technically accept either a BinaryIO or # anything that supports the C++ Buffer Protocol, # which is unspecifiable in type hints. @@ -82,7 +84,7 @@ def decode(data: T.Union[bytes, T.BinaryIO]) -> "constants_t": return constants_t._decode_one(buf) @staticmethod - def _decode_one(buf: T.BinaryIO) -> "constants_t": + def _decode_one(buf: T.BinaryIO) -> constants_t: self = constants_t(_skip_initialize=True) self.epsilon = constants_t._CACHED_STRUCT_0.unpack(buf.read(8))[0] return self @@ -102,7 +104,7 @@ def _get_packed_fingerprint() -> bytes: constants_t._packed_fingerprint = struct.pack(">Q", constants_t._get_hash_recursive([])) return constants_t._packed_fingerprint - def deepcopy(self, **kwargs: T.Any) -> "constants_t": + def deepcopy(self, **kwargs: T.Any) -> constants_t: """ Deep copy of this LCM type diff --git a/test/symforce_function_codegen_test_data/symengine/codegen_python_test_data/python/lcmtypes/codegen_python_test/_states_t.py b/test/symforce_function_codegen_test_data/symengine/codegen_python_test_data/python/lcmtypes/codegen_python_test/_states_t.py index 094deaaa0..becf60c6e 100644 --- a/test/symforce_function_codegen_test_data/symengine/codegen_python_test_data/python/lcmtypes/codegen_python_test/_states_t.py +++ b/test/symforce_function_codegen_test_data/symengine/codegen_python_test_data/python/lcmtypes/codegen_python_test/_states_t.py @@ -4,6 +4,8 @@ # isort: off # mypy: disallow-untyped-defs +from __future__ import annotations + import copy import typing as T @@ -27,7 +29,7 @@ def __init__( @staticmethod def from_all_fields( p: Vector2d, - ) -> "states_t": + ) -> states_t: return states_t( p=p, ) @@ -41,7 +43,7 @@ def _skytype_meta() -> T.Dict[str, str]: ) @classmethod - def _default(cls) -> "states_t": + def _default(cls) -> states_t: return cls() def __repr__(self) -> str: @@ -71,7 +73,7 @@ def _encode_one(self, buf: T.BinaryIO) -> None: self.p._encode_one(buf) @staticmethod - def decode(data: T.Union[bytes, T.BinaryIO]) -> "states_t": + def decode(data: T.Union[bytes, T.BinaryIO]) -> states_t: # NOTE(eric): This function can technically accept either a BinaryIO or # anything that supports the C++ Buffer Protocol, # which is unspecifiable in type hints. @@ -87,7 +89,7 @@ def decode(data: T.Union[bytes, T.BinaryIO]) -> "states_t": return states_t._decode_one(buf) @staticmethod - def _decode_one(buf: T.BinaryIO) -> "states_t": + def _decode_one(buf: T.BinaryIO) -> states_t: self = states_t(_skip_initialize=True) self.p = Vector2d._decode_one(buf) return self @@ -108,7 +110,7 @@ def _get_packed_fingerprint() -> bytes: states_t._packed_fingerprint = struct.pack(">Q", states_t._get_hash_recursive([])) return states_t._packed_fingerprint - def deepcopy(self, **kwargs: T.Any) -> "states_t": + def deepcopy(self, **kwargs: T.Any) -> states_t: """ Deep copy of this LCM type diff --git a/test/symforce_function_codegen_test_data/symengine/codegen_python_test_data/python/lcmtypes/codegen_python_test/_values_vec_t.py b/test/symforce_function_codegen_test_data/symengine/codegen_python_test_data/python/lcmtypes/codegen_python_test/_values_vec_t.py index 1442263ca..05f441999 100644 --- a/test/symforce_function_codegen_test_data/symengine/codegen_python_test_data/python/lcmtypes/codegen_python_test/_values_vec_t.py +++ b/test/symforce_function_codegen_test_data/symengine/codegen_python_test_data/python/lcmtypes/codegen_python_test/_values_vec_t.py @@ -4,6 +4,8 @@ # isort: off # mypy: disallow-untyped-defs +from __future__ import annotations + import copy import typing as T @@ -42,7 +44,7 @@ def from_all_fields( rot_vec: T.List[Vector4d], scalar_vec: T.List[float], list_of_lists: T.List[T.List[Vector4d]], - ) -> "values_vec_t": + ) -> values_vec_t: return values_vec_t( x=x, y=y, @@ -61,7 +63,7 @@ def _skytype_meta() -> T.Dict[str, str]: ) @classmethod - def _default(cls) -> "values_vec_t": + def _default(cls) -> values_vec_t: return cls() def __repr__(self) -> str: @@ -111,7 +113,7 @@ def _encode_one(self, buf: T.BinaryIO) -> None: self.list_of_lists[i0][i1]._encode_one(buf) @staticmethod - def decode(data: T.Union[bytes, T.BinaryIO]) -> "values_vec_t": + def decode(data: T.Union[bytes, T.BinaryIO]) -> values_vec_t: # NOTE(eric): This function can technically accept either a BinaryIO or # anything that supports the C++ Buffer Protocol, # which is unspecifiable in type hints. @@ -127,7 +129,7 @@ def decode(data: T.Union[bytes, T.BinaryIO]) -> "values_vec_t": return values_vec_t._decode_one(buf) @staticmethod - def _decode_one(buf: T.BinaryIO) -> "values_vec_t": + def _decode_one(buf: T.BinaryIO) -> values_vec_t: self = values_vec_t(_skip_initialize=True) self.x, self.y = values_vec_t._CACHED_STRUCT_0.unpack(buf.read(16)) self.rot = Vector4d._decode_one(buf) @@ -158,7 +160,7 @@ def _get_packed_fingerprint() -> bytes: values_vec_t._packed_fingerprint = struct.pack(">Q", values_vec_t._get_hash_recursive([])) return values_vec_t._packed_fingerprint - def deepcopy(self, **kwargs: T.Any) -> "values_vec_t": + def deepcopy(self, **kwargs: T.Any) -> values_vec_t: """ Deep copy of this LCM type diff --git a/test/symforce_function_codegen_test_data/symengine/with_jacobians_values/python/lcmtypes/sym/_d_out_t.py b/test/symforce_function_codegen_test_data/symengine/with_jacobians_values/python/lcmtypes/sym/_d_out_t.py index 5f182bd69..750ae1106 100644 --- a/test/symforce_function_codegen_test_data/symengine/with_jacobians_values/python/lcmtypes/sym/_d_out_t.py +++ b/test/symforce_function_codegen_test_data/symengine/with_jacobians_values/python/lcmtypes/sym/_d_out_t.py @@ -4,6 +4,8 @@ # isort: off # mypy: disallow-untyped-defs +from __future__ import annotations + import copy import typing as T @@ -29,7 +31,7 @@ def __init__( def from_all_fields( x: float, y: float, - ) -> "d_out_t": + ) -> d_out_t: return d_out_t( x=x, y=y, @@ -44,7 +46,7 @@ def _skytype_meta() -> T.Dict[str, str]: ) @classmethod - def _default(cls) -> "d_out_t": + def _default(cls) -> d_out_t: return cls() def __repr__(self) -> str: @@ -71,7 +73,7 @@ def _encode_one(self, buf: T.BinaryIO) -> None: buf.write(d_out_t._CACHED_STRUCT_0.pack(self.x, self.y)) @staticmethod - def decode(data: T.Union[bytes, T.BinaryIO]) -> "d_out_t": + def decode(data: T.Union[bytes, T.BinaryIO]) -> d_out_t: # NOTE(eric): This function can technically accept either a BinaryIO or # anything that supports the C++ Buffer Protocol, # which is unspecifiable in type hints. @@ -87,7 +89,7 @@ def decode(data: T.Union[bytes, T.BinaryIO]) -> "d_out_t": return d_out_t._decode_one(buf) @staticmethod - def _decode_one(buf: T.BinaryIO) -> "d_out_t": + def _decode_one(buf: T.BinaryIO) -> d_out_t: self = d_out_t(_skip_initialize=True) self.x, self.y = d_out_t._CACHED_STRUCT_0.unpack(buf.read(16)) return self @@ -107,7 +109,7 @@ def _get_packed_fingerprint() -> bytes: d_out_t._packed_fingerprint = struct.pack(">Q", d_out_t._get_hash_recursive([])) return d_out_t._packed_fingerprint - def deepcopy(self, **kwargs: T.Any) -> "d_out_t": + def deepcopy(self, **kwargs: T.Any) -> d_out_t: """ Deep copy of this LCM type diff --git a/test/symforce_function_codegen_test_data/symengine/with_jacobians_values/python/lcmtypes/sym/_d_t.py b/test/symforce_function_codegen_test_data/symengine/with_jacobians_values/python/lcmtypes/sym/_d_t.py index 294db3499..1aa83cf33 100644 --- a/test/symforce_function_codegen_test_data/symengine/with_jacobians_values/python/lcmtypes/sym/_d_t.py +++ b/test/symforce_function_codegen_test_data/symengine/with_jacobians_values/python/lcmtypes/sym/_d_t.py @@ -4,6 +4,8 @@ # isort: off # mypy: disallow-untyped-defs +from __future__ import annotations + import copy import typing as T @@ -30,7 +32,7 @@ def __init__( def from_all_fields( x: float, y: Vector2d, - ) -> "d_t": + ) -> d_t: return d_t( x=x, y=y, @@ -45,7 +47,7 @@ def _skytype_meta() -> T.Dict[str, str]: ) @classmethod - def _default(cls) -> "d_t": + def _default(cls) -> d_t: return cls() def __repr__(self) -> str: @@ -77,7 +79,7 @@ def _encode_one(self, buf: T.BinaryIO) -> None: self.y._encode_one(buf) @staticmethod - def decode(data: T.Union[bytes, T.BinaryIO]) -> "d_t": + def decode(data: T.Union[bytes, T.BinaryIO]) -> d_t: # NOTE(eric): This function can technically accept either a BinaryIO or # anything that supports the C++ Buffer Protocol, # which is unspecifiable in type hints. @@ -93,7 +95,7 @@ def decode(data: T.Union[bytes, T.BinaryIO]) -> "d_t": return d_t._decode_one(buf) @staticmethod - def _decode_one(buf: T.BinaryIO) -> "d_t": + def _decode_one(buf: T.BinaryIO) -> d_t: self = d_t(_skip_initialize=True) self.x = d_t._CACHED_STRUCT_0.unpack(buf.read(8))[0] self.y = Vector2d._decode_one(buf) @@ -115,7 +117,7 @@ def _get_packed_fingerprint() -> bytes: d_t._packed_fingerprint = struct.pack(">Q", d_t._get_hash_recursive([])) return d_t._packed_fingerprint - def deepcopy(self, **kwargs: T.Any) -> "d_t": + def deepcopy(self, **kwargs: T.Any) -> d_t: """ Deep copy of this LCM type diff --git a/test/symforce_function_codegen_test_data/sympy/codegen_cpp_test_data/python/lcmtypes/codegen_cpp_test/_constants_t.py b/test/symforce_function_codegen_test_data/sympy/codegen_cpp_test_data/python/lcmtypes/codegen_cpp_test/_constants_t.py index b52467dae..958e6591e 100644 --- a/test/symforce_function_codegen_test_data/sympy/codegen_cpp_test_data/python/lcmtypes/codegen_cpp_test/_constants_t.py +++ b/test/symforce_function_codegen_test_data/sympy/codegen_cpp_test_data/python/lcmtypes/codegen_cpp_test/_constants_t.py @@ -4,6 +4,8 @@ # isort: off # mypy: disallow-untyped-defs +from __future__ import annotations + import copy import typing as T @@ -26,7 +28,7 @@ def __init__( @staticmethod def from_all_fields( epsilon: float, - ) -> "constants_t": + ) -> constants_t: return constants_t( epsilon=epsilon, ) @@ -40,7 +42,7 @@ def _skytype_meta() -> T.Dict[str, str]: ) @classmethod - def _default(cls) -> "constants_t": + def _default(cls) -> constants_t: return cls() def __repr__(self) -> str: @@ -66,7 +68,7 @@ def _encode_one(self, buf: T.BinaryIO) -> None: buf.write(constants_t._CACHED_STRUCT_0.pack(self.epsilon)) @staticmethod - def decode(data: T.Union[bytes, T.BinaryIO]) -> "constants_t": + def decode(data: T.Union[bytes, T.BinaryIO]) -> constants_t: # NOTE(eric): This function can technically accept either a BinaryIO or # anything that supports the C++ Buffer Protocol, # which is unspecifiable in type hints. @@ -82,7 +84,7 @@ def decode(data: T.Union[bytes, T.BinaryIO]) -> "constants_t": return constants_t._decode_one(buf) @staticmethod - def _decode_one(buf: T.BinaryIO) -> "constants_t": + def _decode_one(buf: T.BinaryIO) -> constants_t: self = constants_t(_skip_initialize=True) self.epsilon = constants_t._CACHED_STRUCT_0.unpack(buf.read(8))[0] return self @@ -102,7 +104,7 @@ def _get_packed_fingerprint() -> bytes: constants_t._packed_fingerprint = struct.pack(">Q", constants_t._get_hash_recursive([])) return constants_t._packed_fingerprint - def deepcopy(self, **kwargs: T.Any) -> "constants_t": + def deepcopy(self, **kwargs: T.Any) -> constants_t: """ Deep copy of this LCM type diff --git a/test/symforce_function_codegen_test_data/sympy/codegen_cpp_test_data/python/lcmtypes/codegen_cpp_test/_states_t.py b/test/symforce_function_codegen_test_data/sympy/codegen_cpp_test_data/python/lcmtypes/codegen_cpp_test/_states_t.py index e0f7f1a5a..17a06c86b 100644 --- a/test/symforce_function_codegen_test_data/sympy/codegen_cpp_test_data/python/lcmtypes/codegen_cpp_test/_states_t.py +++ b/test/symforce_function_codegen_test_data/sympy/codegen_cpp_test_data/python/lcmtypes/codegen_cpp_test/_states_t.py @@ -4,6 +4,8 @@ # isort: off # mypy: disallow-untyped-defs +from __future__ import annotations + import copy import typing as T @@ -27,7 +29,7 @@ def __init__( @staticmethod def from_all_fields( p: Vector2d, - ) -> "states_t": + ) -> states_t: return states_t( p=p, ) @@ -41,7 +43,7 @@ def _skytype_meta() -> T.Dict[str, str]: ) @classmethod - def _default(cls) -> "states_t": + def _default(cls) -> states_t: return cls() def __repr__(self) -> str: @@ -71,7 +73,7 @@ def _encode_one(self, buf: T.BinaryIO) -> None: self.p._encode_one(buf) @staticmethod - def decode(data: T.Union[bytes, T.BinaryIO]) -> "states_t": + def decode(data: T.Union[bytes, T.BinaryIO]) -> states_t: # NOTE(eric): This function can technically accept either a BinaryIO or # anything that supports the C++ Buffer Protocol, # which is unspecifiable in type hints. @@ -87,7 +89,7 @@ def decode(data: T.Union[bytes, T.BinaryIO]) -> "states_t": return states_t._decode_one(buf) @staticmethod - def _decode_one(buf: T.BinaryIO) -> "states_t": + def _decode_one(buf: T.BinaryIO) -> states_t: self = states_t(_skip_initialize=True) self.p = Vector2d._decode_one(buf) return self @@ -108,7 +110,7 @@ def _get_packed_fingerprint() -> bytes: states_t._packed_fingerprint = struct.pack(">Q", states_t._get_hash_recursive([])) return states_t._packed_fingerprint - def deepcopy(self, **kwargs: T.Any) -> "states_t": + def deepcopy(self, **kwargs: T.Any) -> states_t: """ Deep copy of this LCM type diff --git a/test/symforce_function_codegen_test_data/sympy/codegen_cpp_test_data/python/lcmtypes/codegen_cpp_test/_values_vec_t.py b/test/symforce_function_codegen_test_data/sympy/codegen_cpp_test_data/python/lcmtypes/codegen_cpp_test/_values_vec_t.py index 6cf7415c3..a3d742205 100644 --- a/test/symforce_function_codegen_test_data/sympy/codegen_cpp_test_data/python/lcmtypes/codegen_cpp_test/_values_vec_t.py +++ b/test/symforce_function_codegen_test_data/sympy/codegen_cpp_test_data/python/lcmtypes/codegen_cpp_test/_values_vec_t.py @@ -4,6 +4,8 @@ # isort: off # mypy: disallow-untyped-defs +from __future__ import annotations + import copy import typing as T @@ -42,7 +44,7 @@ def from_all_fields( rot_vec: T.List[Vector4d], scalar_vec: T.List[float], list_of_lists: T.List[T.List[Vector4d]], - ) -> "values_vec_t": + ) -> values_vec_t: return values_vec_t( x=x, y=y, @@ -61,7 +63,7 @@ def _skytype_meta() -> T.Dict[str, str]: ) @classmethod - def _default(cls) -> "values_vec_t": + def _default(cls) -> values_vec_t: return cls() def __repr__(self) -> str: @@ -111,7 +113,7 @@ def _encode_one(self, buf: T.BinaryIO) -> None: self.list_of_lists[i0][i1]._encode_one(buf) @staticmethod - def decode(data: T.Union[bytes, T.BinaryIO]) -> "values_vec_t": + def decode(data: T.Union[bytes, T.BinaryIO]) -> values_vec_t: # NOTE(eric): This function can technically accept either a BinaryIO or # anything that supports the C++ Buffer Protocol, # which is unspecifiable in type hints. @@ -127,7 +129,7 @@ def decode(data: T.Union[bytes, T.BinaryIO]) -> "values_vec_t": return values_vec_t._decode_one(buf) @staticmethod - def _decode_one(buf: T.BinaryIO) -> "values_vec_t": + def _decode_one(buf: T.BinaryIO) -> values_vec_t: self = values_vec_t(_skip_initialize=True) self.x, self.y = values_vec_t._CACHED_STRUCT_0.unpack(buf.read(16)) self.rot = Vector4d._decode_one(buf) @@ -158,7 +160,7 @@ def _get_packed_fingerprint() -> bytes: values_vec_t._packed_fingerprint = struct.pack(">Q", values_vec_t._get_hash_recursive([])) return values_vec_t._packed_fingerprint - def deepcopy(self, **kwargs: T.Any) -> "values_vec_t": + def deepcopy(self, **kwargs: T.Any) -> values_vec_t: """ Deep copy of this LCM type diff --git a/test/symforce_function_codegen_test_data/sympy/codegen_dataclass_in_values_test_data/python/lcmtypes/codegen_test/_my_dataclass_t.py b/test/symforce_function_codegen_test_data/sympy/codegen_dataclass_in_values_test_data/python/lcmtypes/codegen_test/_my_dataclass_t.py index 8f10dae5b..186493add 100644 --- a/test/symforce_function_codegen_test_data/sympy/codegen_dataclass_in_values_test_data/python/lcmtypes/codegen_test/_my_dataclass_t.py +++ b/test/symforce_function_codegen_test_data/sympy/codegen_dataclass_in_values_test_data/python/lcmtypes/codegen_test/_my_dataclass_t.py @@ -4,6 +4,8 @@ # isort: off # mypy: disallow-untyped-defs +from __future__ import annotations + import copy import typing as T @@ -27,7 +29,7 @@ def __init__( @staticmethod def from_all_fields( rot: Vector4d, - ) -> "my_dataclass_t": + ) -> my_dataclass_t: return my_dataclass_t( rot=rot, ) @@ -41,7 +43,7 @@ def _skytype_meta() -> T.Dict[str, str]: ) @classmethod - def _default(cls) -> "my_dataclass_t": + def _default(cls) -> my_dataclass_t: return cls() def __repr__(self) -> str: @@ -71,7 +73,7 @@ def _encode_one(self, buf: T.BinaryIO) -> None: self.rot._encode_one(buf) @staticmethod - def decode(data: T.Union[bytes, T.BinaryIO]) -> "my_dataclass_t": + def decode(data: T.Union[bytes, T.BinaryIO]) -> my_dataclass_t: # NOTE(eric): This function can technically accept either a BinaryIO or # anything that supports the C++ Buffer Protocol, # which is unspecifiable in type hints. @@ -87,7 +89,7 @@ def decode(data: T.Union[bytes, T.BinaryIO]) -> "my_dataclass_t": return my_dataclass_t._decode_one(buf) @staticmethod - def _decode_one(buf: T.BinaryIO) -> "my_dataclass_t": + def _decode_one(buf: T.BinaryIO) -> my_dataclass_t: self = my_dataclass_t(_skip_initialize=True) self.rot = Vector4d._decode_one(buf) return self @@ -108,7 +110,7 @@ def _get_packed_fingerprint() -> bytes: my_dataclass_t._packed_fingerprint = struct.pack(">Q", my_dataclass_t._get_hash_recursive([])) return my_dataclass_t._packed_fingerprint - def deepcopy(self, **kwargs: T.Any) -> "my_dataclass_t": + def deepcopy(self, **kwargs: T.Any) -> my_dataclass_t: """ Deep copy of this LCM type diff --git a/test/symforce_function_codegen_test_data/sympy/codegen_explicit_template_instantiation_test_data/python/lcmtypes/codegen_explicit_template_instantiation_test/_constants_t.py b/test/symforce_function_codegen_test_data/sympy/codegen_explicit_template_instantiation_test_data/python/lcmtypes/codegen_explicit_template_instantiation_test/_constants_t.py index c8c4446c2..2cbf082c9 100644 --- a/test/symforce_function_codegen_test_data/sympy/codegen_explicit_template_instantiation_test_data/python/lcmtypes/codegen_explicit_template_instantiation_test/_constants_t.py +++ b/test/symforce_function_codegen_test_data/sympy/codegen_explicit_template_instantiation_test_data/python/lcmtypes/codegen_explicit_template_instantiation_test/_constants_t.py @@ -4,6 +4,8 @@ # isort: off # mypy: disallow-untyped-defs +from __future__ import annotations + import copy import typing as T @@ -26,7 +28,7 @@ def __init__( @staticmethod def from_all_fields( epsilon: float, - ) -> "constants_t": + ) -> constants_t: return constants_t( epsilon=epsilon, ) @@ -40,7 +42,7 @@ def _skytype_meta() -> T.Dict[str, str]: ) @classmethod - def _default(cls) -> "constants_t": + def _default(cls) -> constants_t: return cls() def __repr__(self) -> str: @@ -66,7 +68,7 @@ def _encode_one(self, buf: T.BinaryIO) -> None: buf.write(constants_t._CACHED_STRUCT_0.pack(self.epsilon)) @staticmethod - def decode(data: T.Union[bytes, T.BinaryIO]) -> "constants_t": + def decode(data: T.Union[bytes, T.BinaryIO]) -> constants_t: # NOTE(eric): This function can technically accept either a BinaryIO or # anything that supports the C++ Buffer Protocol, # which is unspecifiable in type hints. @@ -82,7 +84,7 @@ def decode(data: T.Union[bytes, T.BinaryIO]) -> "constants_t": return constants_t._decode_one(buf) @staticmethod - def _decode_one(buf: T.BinaryIO) -> "constants_t": + def _decode_one(buf: T.BinaryIO) -> constants_t: self = constants_t(_skip_initialize=True) self.epsilon = constants_t._CACHED_STRUCT_0.unpack(buf.read(8))[0] return self @@ -102,7 +104,7 @@ def _get_packed_fingerprint() -> bytes: constants_t._packed_fingerprint = struct.pack(">Q", constants_t._get_hash_recursive([])) return constants_t._packed_fingerprint - def deepcopy(self, **kwargs: T.Any) -> "constants_t": + def deepcopy(self, **kwargs: T.Any) -> constants_t: """ Deep copy of this LCM type diff --git a/test/symforce_function_codegen_test_data/sympy/codegen_explicit_template_instantiation_test_data/python/lcmtypes/codegen_explicit_template_instantiation_test/_states_t.py b/test/symforce_function_codegen_test_data/sympy/codegen_explicit_template_instantiation_test_data/python/lcmtypes/codegen_explicit_template_instantiation_test/_states_t.py index 04c083b35..f1848f835 100644 --- a/test/symforce_function_codegen_test_data/sympy/codegen_explicit_template_instantiation_test_data/python/lcmtypes/codegen_explicit_template_instantiation_test/_states_t.py +++ b/test/symforce_function_codegen_test_data/sympy/codegen_explicit_template_instantiation_test_data/python/lcmtypes/codegen_explicit_template_instantiation_test/_states_t.py @@ -4,6 +4,8 @@ # isort: off # mypy: disallow-untyped-defs +from __future__ import annotations + import copy import typing as T @@ -27,7 +29,7 @@ def __init__( @staticmethod def from_all_fields( p: Vector2d, - ) -> "states_t": + ) -> states_t: return states_t( p=p, ) @@ -41,7 +43,7 @@ def _skytype_meta() -> T.Dict[str, str]: ) @classmethod - def _default(cls) -> "states_t": + def _default(cls) -> states_t: return cls() def __repr__(self) -> str: @@ -71,7 +73,7 @@ def _encode_one(self, buf: T.BinaryIO) -> None: self.p._encode_one(buf) @staticmethod - def decode(data: T.Union[bytes, T.BinaryIO]) -> "states_t": + def decode(data: T.Union[bytes, T.BinaryIO]) -> states_t: # NOTE(eric): This function can technically accept either a BinaryIO or # anything that supports the C++ Buffer Protocol, # which is unspecifiable in type hints. @@ -87,7 +89,7 @@ def decode(data: T.Union[bytes, T.BinaryIO]) -> "states_t": return states_t._decode_one(buf) @staticmethod - def _decode_one(buf: T.BinaryIO) -> "states_t": + def _decode_one(buf: T.BinaryIO) -> states_t: self = states_t(_skip_initialize=True) self.p = Vector2d._decode_one(buf) return self @@ -108,7 +110,7 @@ def _get_packed_fingerprint() -> bytes: states_t._packed_fingerprint = struct.pack(">Q", states_t._get_hash_recursive([])) return states_t._packed_fingerprint - def deepcopy(self, **kwargs: T.Any) -> "states_t": + def deepcopy(self, **kwargs: T.Any) -> states_t: """ Deep copy of this LCM type diff --git a/test/symforce_function_codegen_test_data/sympy/codegen_explicit_template_instantiation_test_data/python/lcmtypes/codegen_explicit_template_instantiation_test/_values_vec_t.py b/test/symforce_function_codegen_test_data/sympy/codegen_explicit_template_instantiation_test_data/python/lcmtypes/codegen_explicit_template_instantiation_test/_values_vec_t.py index 80ccbc352..2391fea10 100644 --- a/test/symforce_function_codegen_test_data/sympy/codegen_explicit_template_instantiation_test_data/python/lcmtypes/codegen_explicit_template_instantiation_test/_values_vec_t.py +++ b/test/symforce_function_codegen_test_data/sympy/codegen_explicit_template_instantiation_test_data/python/lcmtypes/codegen_explicit_template_instantiation_test/_values_vec_t.py @@ -4,6 +4,8 @@ # isort: off # mypy: disallow-untyped-defs +from __future__ import annotations + import copy import typing as T @@ -42,7 +44,7 @@ def from_all_fields( rot_vec: T.List[Vector4d], scalar_vec: T.List[float], list_of_lists: T.List[T.List[Vector4d]], - ) -> "values_vec_t": + ) -> values_vec_t: return values_vec_t( x=x, y=y, @@ -61,7 +63,7 @@ def _skytype_meta() -> T.Dict[str, str]: ) @classmethod - def _default(cls) -> "values_vec_t": + def _default(cls) -> values_vec_t: return cls() def __repr__(self) -> str: @@ -111,7 +113,7 @@ def _encode_one(self, buf: T.BinaryIO) -> None: self.list_of_lists[i0][i1]._encode_one(buf) @staticmethod - def decode(data: T.Union[bytes, T.BinaryIO]) -> "values_vec_t": + def decode(data: T.Union[bytes, T.BinaryIO]) -> values_vec_t: # NOTE(eric): This function can technically accept either a BinaryIO or # anything that supports the C++ Buffer Protocol, # which is unspecifiable in type hints. @@ -127,7 +129,7 @@ def decode(data: T.Union[bytes, T.BinaryIO]) -> "values_vec_t": return values_vec_t._decode_one(buf) @staticmethod - def _decode_one(buf: T.BinaryIO) -> "values_vec_t": + def _decode_one(buf: T.BinaryIO) -> values_vec_t: self = values_vec_t(_skip_initialize=True) self.x, self.y = values_vec_t._CACHED_STRUCT_0.unpack(buf.read(16)) self.rot = Vector4d._decode_one(buf) @@ -158,7 +160,7 @@ def _get_packed_fingerprint() -> bytes: values_vec_t._packed_fingerprint = struct.pack(">Q", values_vec_t._get_hash_recursive([])) return values_vec_t._packed_fingerprint - def deepcopy(self, **kwargs: T.Any) -> "values_vec_t": + def deepcopy(self, **kwargs: T.Any) -> values_vec_t: """ Deep copy of this LCM type diff --git a/test/symforce_function_codegen_test_data/sympy/codegen_multi_function_test_data/python/lcmtypes/codegen_multi_function_test/_inputs_constants_t.py b/test/symforce_function_codegen_test_data/sympy/codegen_multi_function_test_data/python/lcmtypes/codegen_multi_function_test/_inputs_constants_t.py index 66310104b..5bafc7b28 100644 --- a/test/symforce_function_codegen_test_data/sympy/codegen_multi_function_test_data/python/lcmtypes/codegen_multi_function_test/_inputs_constants_t.py +++ b/test/symforce_function_codegen_test_data/sympy/codegen_multi_function_test_data/python/lcmtypes/codegen_multi_function_test/_inputs_constants_t.py @@ -4,6 +4,8 @@ # isort: off # mypy: disallow-untyped-defs +from __future__ import annotations + import copy import typing as T @@ -26,7 +28,7 @@ def __init__( @staticmethod def from_all_fields( epsilon: float, - ) -> "inputs_constants_t": + ) -> inputs_constants_t: return inputs_constants_t( epsilon=epsilon, ) @@ -40,7 +42,7 @@ def _skytype_meta() -> T.Dict[str, str]: ) @classmethod - def _default(cls) -> "inputs_constants_t": + def _default(cls) -> inputs_constants_t: return cls() def __repr__(self) -> str: @@ -66,7 +68,7 @@ def _encode_one(self, buf: T.BinaryIO) -> None: buf.write(inputs_constants_t._CACHED_STRUCT_0.pack(self.epsilon)) @staticmethod - def decode(data: T.Union[bytes, T.BinaryIO]) -> "inputs_constants_t": + def decode(data: T.Union[bytes, T.BinaryIO]) -> inputs_constants_t: # NOTE(eric): This function can technically accept either a BinaryIO or # anything that supports the C++ Buffer Protocol, # which is unspecifiable in type hints. @@ -82,7 +84,7 @@ def decode(data: T.Union[bytes, T.BinaryIO]) -> "inputs_constants_t": return inputs_constants_t._decode_one(buf) @staticmethod - def _decode_one(buf: T.BinaryIO) -> "inputs_constants_t": + def _decode_one(buf: T.BinaryIO) -> inputs_constants_t: self = inputs_constants_t(_skip_initialize=True) self.epsilon = inputs_constants_t._CACHED_STRUCT_0.unpack(buf.read(8))[0] return self @@ -102,7 +104,7 @@ def _get_packed_fingerprint() -> bytes: inputs_constants_t._packed_fingerprint = struct.pack(">Q", inputs_constants_t._get_hash_recursive([])) return inputs_constants_t._packed_fingerprint - def deepcopy(self, **kwargs: T.Any) -> "inputs_constants_t": + def deepcopy(self, **kwargs: T.Any) -> inputs_constants_t: """ Deep copy of this LCM type diff --git a/test/symforce_function_codegen_test_data/sympy/codegen_multi_function_test_data/python/lcmtypes/codegen_multi_function_test/_inputs_states_t.py b/test/symforce_function_codegen_test_data/sympy/codegen_multi_function_test_data/python/lcmtypes/codegen_multi_function_test/_inputs_states_t.py index 44b28b2ef..80a382284 100644 --- a/test/symforce_function_codegen_test_data/sympy/codegen_multi_function_test_data/python/lcmtypes/codegen_multi_function_test/_inputs_states_t.py +++ b/test/symforce_function_codegen_test_data/sympy/codegen_multi_function_test_data/python/lcmtypes/codegen_multi_function_test/_inputs_states_t.py @@ -4,6 +4,8 @@ # isort: off # mypy: disallow-untyped-defs +from __future__ import annotations + import copy import typing as T @@ -27,7 +29,7 @@ def __init__( @staticmethod def from_all_fields( p: Vector2d, - ) -> "inputs_states_t": + ) -> inputs_states_t: return inputs_states_t( p=p, ) @@ -41,7 +43,7 @@ def _skytype_meta() -> T.Dict[str, str]: ) @classmethod - def _default(cls) -> "inputs_states_t": + def _default(cls) -> inputs_states_t: return cls() def __repr__(self) -> str: @@ -71,7 +73,7 @@ def _encode_one(self, buf: T.BinaryIO) -> None: self.p._encode_one(buf) @staticmethod - def decode(data: T.Union[bytes, T.BinaryIO]) -> "inputs_states_t": + def decode(data: T.Union[bytes, T.BinaryIO]) -> inputs_states_t: # NOTE(eric): This function can technically accept either a BinaryIO or # anything that supports the C++ Buffer Protocol, # which is unspecifiable in type hints. @@ -87,7 +89,7 @@ def decode(data: T.Union[bytes, T.BinaryIO]) -> "inputs_states_t": return inputs_states_t._decode_one(buf) @staticmethod - def _decode_one(buf: T.BinaryIO) -> "inputs_states_t": + def _decode_one(buf: T.BinaryIO) -> inputs_states_t: self = inputs_states_t(_skip_initialize=True) self.p = Vector2d._decode_one(buf) return self @@ -108,7 +110,7 @@ def _get_packed_fingerprint() -> bytes: inputs_states_t._packed_fingerprint = struct.pack(">Q", inputs_states_t._get_hash_recursive([])) return inputs_states_t._packed_fingerprint - def deepcopy(self, **kwargs: T.Any) -> "inputs_states_t": + def deepcopy(self, **kwargs: T.Any) -> inputs_states_t: """ Deep copy of this LCM type diff --git a/test/symforce_function_codegen_test_data/sympy/codegen_multi_function_test_data/python/lcmtypes/codegen_multi_function_test/_inputs_t.py b/test/symforce_function_codegen_test_data/sympy/codegen_multi_function_test_data/python/lcmtypes/codegen_multi_function_test/_inputs_t.py index e9ac7b16a..8daa0acb8 100644 --- a/test/symforce_function_codegen_test_data/sympy/codegen_multi_function_test_data/python/lcmtypes/codegen_multi_function_test/_inputs_t.py +++ b/test/symforce_function_codegen_test_data/sympy/codegen_multi_function_test_data/python/lcmtypes/codegen_multi_function_test/_inputs_t.py @@ -4,6 +4,8 @@ # isort: off # mypy: disallow-untyped-defs +from __future__ import annotations + import copy import typing as T @@ -65,7 +67,7 @@ def from_all_fields( big_matrix: MatrixXd, small_matrix: Matrix4d, states: inputs_states_t, - ) -> "inputs_t": + ) -> inputs_t: return inputs_t( x=x, y=y, @@ -90,7 +92,7 @@ def _skytype_meta() -> T.Dict[str, str]: ) @classmethod - def _default(cls) -> "inputs_t": + def _default(cls) -> inputs_t: return cls() def __repr__(self) -> str: @@ -179,7 +181,7 @@ def _encode_one(self, buf: T.BinaryIO) -> None: self.states._encode_one(buf) @staticmethod - def decode(data: T.Union[bytes, T.BinaryIO]) -> "inputs_t": + def decode(data: T.Union[bytes, T.BinaryIO]) -> inputs_t: # NOTE(eric): This function can technically accept either a BinaryIO or # anything that supports the C++ Buffer Protocol, # which is unspecifiable in type hints. @@ -195,7 +197,7 @@ def decode(data: T.Union[bytes, T.BinaryIO]) -> "inputs_t": return inputs_t._decode_one(buf) @staticmethod - def _decode_one(buf: T.BinaryIO) -> "inputs_t": + def _decode_one(buf: T.BinaryIO) -> inputs_t: self = inputs_t(_skip_initialize=True) self.x, self.y = inputs_t._CACHED_STRUCT_0.unpack(buf.read(16)) self.rot = Vector4d._decode_one(buf) @@ -238,7 +240,7 @@ def _get_packed_fingerprint() -> bytes: inputs_t._packed_fingerprint = struct.pack(">Q", inputs_t._get_hash_recursive([])) return inputs_t._packed_fingerprint - def deepcopy(self, **kwargs: T.Any) -> "inputs_t": + def deepcopy(self, **kwargs: T.Any) -> inputs_t: """ Deep copy of this LCM type diff --git a/test/symforce_function_codegen_test_data/sympy/codegen_multi_function_test_data/python/lcmtypes/codegen_multi_function_test/_outputs_1_t.py b/test/symforce_function_codegen_test_data/sympy/codegen_multi_function_test_data/python/lcmtypes/codegen_multi_function_test/_outputs_1_t.py index 37e882e3a..d128924a7 100644 --- a/test/symforce_function_codegen_test_data/sympy/codegen_multi_function_test_data/python/lcmtypes/codegen_multi_function_test/_outputs_1_t.py +++ b/test/symforce_function_codegen_test_data/sympy/codegen_multi_function_test_data/python/lcmtypes/codegen_multi_function_test/_outputs_1_t.py @@ -4,6 +4,8 @@ # isort: off # mypy: disallow-untyped-defs +from __future__ import annotations + import copy import typing as T @@ -47,7 +49,7 @@ def from_all_fields( values_vec_2D_out: T.List[T.List[values_vec_t]], big_matrix_from_small_matrix: MatrixXd, small_matrix_from_big_matrix: Matrix4d, - ) -> "outputs_1_t": + ) -> outputs_1_t: return outputs_1_t( foo=foo, bar=bar, @@ -67,7 +69,7 @@ def _skytype_meta() -> T.Dict[str, str]: ) @classmethod - def _default(cls) -> "outputs_1_t": + def _default(cls) -> outputs_1_t: return cls() def __repr__(self) -> str: @@ -123,7 +125,7 @@ def _encode_one(self, buf: T.BinaryIO) -> None: self.small_matrix_from_big_matrix._encode_one(buf) @staticmethod - def decode(data: T.Union[bytes, T.BinaryIO]) -> "outputs_1_t": + def decode(data: T.Union[bytes, T.BinaryIO]) -> outputs_1_t: # NOTE(eric): This function can technically accept either a BinaryIO or # anything that supports the C++ Buffer Protocol, # which is unspecifiable in type hints. @@ -139,7 +141,7 @@ def decode(data: T.Union[bytes, T.BinaryIO]) -> "outputs_1_t": return outputs_1_t._decode_one(buf) @staticmethod - def _decode_one(buf: T.BinaryIO) -> "outputs_1_t": + def _decode_one(buf: T.BinaryIO) -> outputs_1_t: self = outputs_1_t(_skip_initialize=True) self.foo, self.bar = outputs_1_t._CACHED_STRUCT_0.unpack(buf.read(16)) self.scalar_vec_out = list(outputs_1_t._CACHED_STRUCT_1.unpack(buf.read(24))) @@ -171,7 +173,7 @@ def _get_packed_fingerprint() -> bytes: outputs_1_t._packed_fingerprint = struct.pack(">Q", outputs_1_t._get_hash_recursive([])) return outputs_1_t._packed_fingerprint - def deepcopy(self, **kwargs: T.Any) -> "outputs_1_t": + def deepcopy(self, **kwargs: T.Any) -> outputs_1_t: """ Deep copy of this LCM type diff --git a/test/symforce_function_codegen_test_data/sympy/codegen_multi_function_test_data/python/lcmtypes/codegen_multi_function_test/_outputs_2_t.py b/test/symforce_function_codegen_test_data/sympy/codegen_multi_function_test_data/python/lcmtypes/codegen_multi_function_test/_outputs_2_t.py index eb0ad1637..b6f640e20 100644 --- a/test/symforce_function_codegen_test_data/sympy/codegen_multi_function_test_data/python/lcmtypes/codegen_multi_function_test/_outputs_2_t.py +++ b/test/symforce_function_codegen_test_data/sympy/codegen_multi_function_test_data/python/lcmtypes/codegen_multi_function_test/_outputs_2_t.py @@ -4,6 +4,8 @@ # isort: off # mypy: disallow-untyped-defs +from __future__ import annotations + import copy import typing as T @@ -26,7 +28,7 @@ def __init__( @staticmethod def from_all_fields( foo: float, - ) -> "outputs_2_t": + ) -> outputs_2_t: return outputs_2_t( foo=foo, ) @@ -40,7 +42,7 @@ def _skytype_meta() -> T.Dict[str, str]: ) @classmethod - def _default(cls) -> "outputs_2_t": + def _default(cls) -> outputs_2_t: return cls() def __repr__(self) -> str: @@ -66,7 +68,7 @@ def _encode_one(self, buf: T.BinaryIO) -> None: buf.write(outputs_2_t._CACHED_STRUCT_0.pack(self.foo)) @staticmethod - def decode(data: T.Union[bytes, T.BinaryIO]) -> "outputs_2_t": + def decode(data: T.Union[bytes, T.BinaryIO]) -> outputs_2_t: # NOTE(eric): This function can technically accept either a BinaryIO or # anything that supports the C++ Buffer Protocol, # which is unspecifiable in type hints. @@ -82,7 +84,7 @@ def decode(data: T.Union[bytes, T.BinaryIO]) -> "outputs_2_t": return outputs_2_t._decode_one(buf) @staticmethod - def _decode_one(buf: T.BinaryIO) -> "outputs_2_t": + def _decode_one(buf: T.BinaryIO) -> outputs_2_t: self = outputs_2_t(_skip_initialize=True) self.foo = outputs_2_t._CACHED_STRUCT_0.unpack(buf.read(8))[0] return self @@ -102,7 +104,7 @@ def _get_packed_fingerprint() -> bytes: outputs_2_t._packed_fingerprint = struct.pack(">Q", outputs_2_t._get_hash_recursive([])) return outputs_2_t._packed_fingerprint - def deepcopy(self, **kwargs: T.Any) -> "outputs_2_t": + def deepcopy(self, **kwargs: T.Any) -> outputs_2_t: """ Deep copy of this LCM type diff --git a/test/symforce_function_codegen_test_data/sympy/codegen_multi_function_test_data/python/lcmtypes/codegen_multi_function_test/_values_vec_t.py b/test/symforce_function_codegen_test_data/sympy/codegen_multi_function_test_data/python/lcmtypes/codegen_multi_function_test/_values_vec_t.py index 87518da02..df1d62161 100644 --- a/test/symforce_function_codegen_test_data/sympy/codegen_multi_function_test_data/python/lcmtypes/codegen_multi_function_test/_values_vec_t.py +++ b/test/symforce_function_codegen_test_data/sympy/codegen_multi_function_test_data/python/lcmtypes/codegen_multi_function_test/_values_vec_t.py @@ -4,6 +4,8 @@ # isort: off # mypy: disallow-untyped-defs +from __future__ import annotations + import copy import typing as T @@ -42,7 +44,7 @@ def from_all_fields( rot_vec: T.List[Vector4d], scalar_vec: T.List[float], list_of_lists: T.List[T.List[Vector4d]], - ) -> "values_vec_t": + ) -> values_vec_t: return values_vec_t( x=x, y=y, @@ -61,7 +63,7 @@ def _skytype_meta() -> T.Dict[str, str]: ) @classmethod - def _default(cls) -> "values_vec_t": + def _default(cls) -> values_vec_t: return cls() def __repr__(self) -> str: @@ -111,7 +113,7 @@ def _encode_one(self, buf: T.BinaryIO) -> None: self.list_of_lists[i0][i1]._encode_one(buf) @staticmethod - def decode(data: T.Union[bytes, T.BinaryIO]) -> "values_vec_t": + def decode(data: T.Union[bytes, T.BinaryIO]) -> values_vec_t: # NOTE(eric): This function can technically accept either a BinaryIO or # anything that supports the C++ Buffer Protocol, # which is unspecifiable in type hints. @@ -127,7 +129,7 @@ def decode(data: T.Union[bytes, T.BinaryIO]) -> "values_vec_t": return values_vec_t._decode_one(buf) @staticmethod - def _decode_one(buf: T.BinaryIO) -> "values_vec_t": + def _decode_one(buf: T.BinaryIO) -> values_vec_t: self = values_vec_t(_skip_initialize=True) self.x, self.y = values_vec_t._CACHED_STRUCT_0.unpack(buf.read(16)) self.rot = Vector4d._decode_one(buf) @@ -158,7 +160,7 @@ def _get_packed_fingerprint() -> bytes: values_vec_t._packed_fingerprint = struct.pack(">Q", values_vec_t._get_hash_recursive([])) return values_vec_t._packed_fingerprint - def deepcopy(self, **kwargs: T.Any) -> "values_vec_t": + def deepcopy(self, **kwargs: T.Any) -> values_vec_t: """ Deep copy of this LCM type diff --git a/test/symforce_function_codegen_test_data/sympy/codegen_python_test_data/python/lcmtypes/codegen_python_test/_constants_t.py b/test/symforce_function_codegen_test_data/sympy/codegen_python_test_data/python/lcmtypes/codegen_python_test/_constants_t.py index 9bb48c1ee..d5cde170d 100644 --- a/test/symforce_function_codegen_test_data/sympy/codegen_python_test_data/python/lcmtypes/codegen_python_test/_constants_t.py +++ b/test/symforce_function_codegen_test_data/sympy/codegen_python_test_data/python/lcmtypes/codegen_python_test/_constants_t.py @@ -4,6 +4,8 @@ # isort: off # mypy: disallow-untyped-defs +from __future__ import annotations + import copy import typing as T @@ -26,7 +28,7 @@ def __init__( @staticmethod def from_all_fields( epsilon: float, - ) -> "constants_t": + ) -> constants_t: return constants_t( epsilon=epsilon, ) @@ -40,7 +42,7 @@ def _skytype_meta() -> T.Dict[str, str]: ) @classmethod - def _default(cls) -> "constants_t": + def _default(cls) -> constants_t: return cls() def __repr__(self) -> str: @@ -66,7 +68,7 @@ def _encode_one(self, buf: T.BinaryIO) -> None: buf.write(constants_t._CACHED_STRUCT_0.pack(self.epsilon)) @staticmethod - def decode(data: T.Union[bytes, T.BinaryIO]) -> "constants_t": + def decode(data: T.Union[bytes, T.BinaryIO]) -> constants_t: # NOTE(eric): This function can technically accept either a BinaryIO or # anything that supports the C++ Buffer Protocol, # which is unspecifiable in type hints. @@ -82,7 +84,7 @@ def decode(data: T.Union[bytes, T.BinaryIO]) -> "constants_t": return constants_t._decode_one(buf) @staticmethod - def _decode_one(buf: T.BinaryIO) -> "constants_t": + def _decode_one(buf: T.BinaryIO) -> constants_t: self = constants_t(_skip_initialize=True) self.epsilon = constants_t._CACHED_STRUCT_0.unpack(buf.read(8))[0] return self @@ -102,7 +104,7 @@ def _get_packed_fingerprint() -> bytes: constants_t._packed_fingerprint = struct.pack(">Q", constants_t._get_hash_recursive([])) return constants_t._packed_fingerprint - def deepcopy(self, **kwargs: T.Any) -> "constants_t": + def deepcopy(self, **kwargs: T.Any) -> constants_t: """ Deep copy of this LCM type diff --git a/test/symforce_function_codegen_test_data/sympy/codegen_python_test_data/python/lcmtypes/codegen_python_test/_states_t.py b/test/symforce_function_codegen_test_data/sympy/codegen_python_test_data/python/lcmtypes/codegen_python_test/_states_t.py index 094deaaa0..becf60c6e 100644 --- a/test/symforce_function_codegen_test_data/sympy/codegen_python_test_data/python/lcmtypes/codegen_python_test/_states_t.py +++ b/test/symforce_function_codegen_test_data/sympy/codegen_python_test_data/python/lcmtypes/codegen_python_test/_states_t.py @@ -4,6 +4,8 @@ # isort: off # mypy: disallow-untyped-defs +from __future__ import annotations + import copy import typing as T @@ -27,7 +29,7 @@ def __init__( @staticmethod def from_all_fields( p: Vector2d, - ) -> "states_t": + ) -> states_t: return states_t( p=p, ) @@ -41,7 +43,7 @@ def _skytype_meta() -> T.Dict[str, str]: ) @classmethod - def _default(cls) -> "states_t": + def _default(cls) -> states_t: return cls() def __repr__(self) -> str: @@ -71,7 +73,7 @@ def _encode_one(self, buf: T.BinaryIO) -> None: self.p._encode_one(buf) @staticmethod - def decode(data: T.Union[bytes, T.BinaryIO]) -> "states_t": + def decode(data: T.Union[bytes, T.BinaryIO]) -> states_t: # NOTE(eric): This function can technically accept either a BinaryIO or # anything that supports the C++ Buffer Protocol, # which is unspecifiable in type hints. @@ -87,7 +89,7 @@ def decode(data: T.Union[bytes, T.BinaryIO]) -> "states_t": return states_t._decode_one(buf) @staticmethod - def _decode_one(buf: T.BinaryIO) -> "states_t": + def _decode_one(buf: T.BinaryIO) -> states_t: self = states_t(_skip_initialize=True) self.p = Vector2d._decode_one(buf) return self @@ -108,7 +110,7 @@ def _get_packed_fingerprint() -> bytes: states_t._packed_fingerprint = struct.pack(">Q", states_t._get_hash_recursive([])) return states_t._packed_fingerprint - def deepcopy(self, **kwargs: T.Any) -> "states_t": + def deepcopy(self, **kwargs: T.Any) -> states_t: """ Deep copy of this LCM type diff --git a/test/symforce_function_codegen_test_data/sympy/codegen_python_test_data/python/lcmtypes/codegen_python_test/_values_vec_t.py b/test/symforce_function_codegen_test_data/sympy/codegen_python_test_data/python/lcmtypes/codegen_python_test/_values_vec_t.py index 1442263ca..05f441999 100644 --- a/test/symforce_function_codegen_test_data/sympy/codegen_python_test_data/python/lcmtypes/codegen_python_test/_values_vec_t.py +++ b/test/symforce_function_codegen_test_data/sympy/codegen_python_test_data/python/lcmtypes/codegen_python_test/_values_vec_t.py @@ -4,6 +4,8 @@ # isort: off # mypy: disallow-untyped-defs +from __future__ import annotations + import copy import typing as T @@ -42,7 +44,7 @@ def from_all_fields( rot_vec: T.List[Vector4d], scalar_vec: T.List[float], list_of_lists: T.List[T.List[Vector4d]], - ) -> "values_vec_t": + ) -> values_vec_t: return values_vec_t( x=x, y=y, @@ -61,7 +63,7 @@ def _skytype_meta() -> T.Dict[str, str]: ) @classmethod - def _default(cls) -> "values_vec_t": + def _default(cls) -> values_vec_t: return cls() def __repr__(self) -> str: @@ -111,7 +113,7 @@ def _encode_one(self, buf: T.BinaryIO) -> None: self.list_of_lists[i0][i1]._encode_one(buf) @staticmethod - def decode(data: T.Union[bytes, T.BinaryIO]) -> "values_vec_t": + def decode(data: T.Union[bytes, T.BinaryIO]) -> values_vec_t: # NOTE(eric): This function can technically accept either a BinaryIO or # anything that supports the C++ Buffer Protocol, # which is unspecifiable in type hints. @@ -127,7 +129,7 @@ def decode(data: T.Union[bytes, T.BinaryIO]) -> "values_vec_t": return values_vec_t._decode_one(buf) @staticmethod - def _decode_one(buf: T.BinaryIO) -> "values_vec_t": + def _decode_one(buf: T.BinaryIO) -> values_vec_t: self = values_vec_t(_skip_initialize=True) self.x, self.y = values_vec_t._CACHED_STRUCT_0.unpack(buf.read(16)) self.rot = Vector4d._decode_one(buf) @@ -158,7 +160,7 @@ def _get_packed_fingerprint() -> bytes: values_vec_t._packed_fingerprint = struct.pack(">Q", values_vec_t._get_hash_recursive([])) return values_vec_t._packed_fingerprint - def deepcopy(self, **kwargs: T.Any) -> "values_vec_t": + def deepcopy(self, **kwargs: T.Any) -> values_vec_t: """ Deep copy of this LCM type diff --git a/test/symforce_function_codegen_test_data/sympy/with_jacobians_values/python/lcmtypes/sym/_d_out_t.py b/test/symforce_function_codegen_test_data/sympy/with_jacobians_values/python/lcmtypes/sym/_d_out_t.py index 5f182bd69..750ae1106 100644 --- a/test/symforce_function_codegen_test_data/sympy/with_jacobians_values/python/lcmtypes/sym/_d_out_t.py +++ b/test/symforce_function_codegen_test_data/sympy/with_jacobians_values/python/lcmtypes/sym/_d_out_t.py @@ -4,6 +4,8 @@ # isort: off # mypy: disallow-untyped-defs +from __future__ import annotations + import copy import typing as T @@ -29,7 +31,7 @@ def __init__( def from_all_fields( x: float, y: float, - ) -> "d_out_t": + ) -> d_out_t: return d_out_t( x=x, y=y, @@ -44,7 +46,7 @@ def _skytype_meta() -> T.Dict[str, str]: ) @classmethod - def _default(cls) -> "d_out_t": + def _default(cls) -> d_out_t: return cls() def __repr__(self) -> str: @@ -71,7 +73,7 @@ def _encode_one(self, buf: T.BinaryIO) -> None: buf.write(d_out_t._CACHED_STRUCT_0.pack(self.x, self.y)) @staticmethod - def decode(data: T.Union[bytes, T.BinaryIO]) -> "d_out_t": + def decode(data: T.Union[bytes, T.BinaryIO]) -> d_out_t: # NOTE(eric): This function can technically accept either a BinaryIO or # anything that supports the C++ Buffer Protocol, # which is unspecifiable in type hints. @@ -87,7 +89,7 @@ def decode(data: T.Union[bytes, T.BinaryIO]) -> "d_out_t": return d_out_t._decode_one(buf) @staticmethod - def _decode_one(buf: T.BinaryIO) -> "d_out_t": + def _decode_one(buf: T.BinaryIO) -> d_out_t: self = d_out_t(_skip_initialize=True) self.x, self.y = d_out_t._CACHED_STRUCT_0.unpack(buf.read(16)) return self @@ -107,7 +109,7 @@ def _get_packed_fingerprint() -> bytes: d_out_t._packed_fingerprint = struct.pack(">Q", d_out_t._get_hash_recursive([])) return d_out_t._packed_fingerprint - def deepcopy(self, **kwargs: T.Any) -> "d_out_t": + def deepcopy(self, **kwargs: T.Any) -> d_out_t: """ Deep copy of this LCM type diff --git a/test/symforce_function_codegen_test_data/sympy/with_jacobians_values/python/lcmtypes/sym/_d_t.py b/test/symforce_function_codegen_test_data/sympy/with_jacobians_values/python/lcmtypes/sym/_d_t.py index 294db3499..1aa83cf33 100644 --- a/test/symforce_function_codegen_test_data/sympy/with_jacobians_values/python/lcmtypes/sym/_d_t.py +++ b/test/symforce_function_codegen_test_data/sympy/with_jacobians_values/python/lcmtypes/sym/_d_t.py @@ -4,6 +4,8 @@ # isort: off # mypy: disallow-untyped-defs +from __future__ import annotations + import copy import typing as T @@ -30,7 +32,7 @@ def __init__( def from_all_fields( x: float, y: Vector2d, - ) -> "d_t": + ) -> d_t: return d_t( x=x, y=y, @@ -45,7 +47,7 @@ def _skytype_meta() -> T.Dict[str, str]: ) @classmethod - def _default(cls) -> "d_t": + def _default(cls) -> d_t: return cls() def __repr__(self) -> str: @@ -77,7 +79,7 @@ def _encode_one(self, buf: T.BinaryIO) -> None: self.y._encode_one(buf) @staticmethod - def decode(data: T.Union[bytes, T.BinaryIO]) -> "d_t": + def decode(data: T.Union[bytes, T.BinaryIO]) -> d_t: # NOTE(eric): This function can technically accept either a BinaryIO or # anything that supports the C++ Buffer Protocol, # which is unspecifiable in type hints. @@ -93,7 +95,7 @@ def decode(data: T.Union[bytes, T.BinaryIO]) -> "d_t": return d_t._decode_one(buf) @staticmethod - def _decode_one(buf: T.BinaryIO) -> "d_t": + def _decode_one(buf: T.BinaryIO) -> d_t: self = d_t(_skip_initialize=True) self.x = d_t._CACHED_STRUCT_0.unpack(buf.read(8))[0] self.y = Vector2d._decode_one(buf) @@ -115,7 +117,7 @@ def _get_packed_fingerprint() -> bytes: d_t._packed_fingerprint = struct.pack(">Q", d_t._get_hash_recursive([])) return d_t._packed_fingerprint - def deepcopy(self, **kwargs: T.Any) -> "d_t": + def deepcopy(self, **kwargs: T.Any) -> d_t: """ Deep copy of this LCM type diff --git a/third_party/skymarshal/skymarshal/templates/python_enum.py.template b/third_party/skymarshal/skymarshal/templates/python_enum.py.template index 254871c4f..1cb233e72 100644 --- a/third_party/skymarshal/skymarshal/templates/python_enum.py.template +++ b/third_party/skymarshal/skymarshal/templates/python_enum.py.template @@ -11,13 +11,11 @@ class {{enumtype.name}}(enum.Enum): {{case.name}} = {{case.int_value}} {% endfor %} - def __repr__(self): - # type: () -> str + def __repr__(self) -> str: return "{}.{}".format(self.__class__.__name__, self.name) @staticmethod - def _skytype_meta(): - # type: () -> T.Dict[str, str] + def _skytype_meta() -> T.Dict[str, str]: return dict( type="enum", package="{{enumtype.package.name}}", @@ -25,25 +23,21 @@ class {{enumtype.name}}(enum.Enum): ) @classmethod - def _default(cls): - # type: () -> {{enumtype.name}} + def _default(cls) -> {{enumtype.name}}: # Return the first enum case return list(cls)[0] - def encode(self): - # type: () -> bytes + def encode(self) -> bytes: buf = BytesIO() buf.write(self._get_packed_fingerprint()) self._encode_one(buf) return buf.getvalue() - def _encode_one(self, buf): - # type: (T.BinaryIO) -> None + def _encode_one(self, buf: T.BinaryIO) -> None: {{ enumtype.encode_value() }} @classmethod - def decode(cls, data): - # type: (T.Union[bytes, T.BinaryIO]) -> {{enumtype.name}} + def decode(cls, data: T.Union[bytes, T.BinaryIO]) -> {{enumtype.name}}: # NOTE(eric): This function can technically accept either a BinaryIO or # anything that supports the C++ Buffer Protocol, # which is unspecifiable in type hints. @@ -59,8 +53,7 @@ class {{enumtype.name}}(enum.Enum): return cls._decode_one(buf) @classmethod - def _decode_one(cls, buf): - # type: (T.BinaryIO) -> {{enumtype.name}} + def _decode_one(cls, buf: T.BinaryIO) -> {{enumtype.name}}: value = {{ enumtype.decode_value() }} result = cls.from_int(value) if result is None: @@ -69,19 +62,18 @@ class {{enumtype.name}}(enum.Enum): @T.overload @classmethod - def from_int(cls, value, default): - # type: (int, {{enumtype.name}}) -> {{enumtype.name}} + def from_int(cls, value: int, default: {{enumtype.name}}) -> {{enumtype.name}}: pass @T.overload @classmethod - def from_int(cls, value, default=None): - # type: (int, None) -> T.Optional[{{enumtype.name}}] + def from_int(cls, value: int, default: None = None) -> T.Optional[{{enumtype.name}}]: pass @classmethod - def from_int(cls, value, default=None): - # type: (int, T.Optional[{{enumtype.name}}]) -> T.Optional[{{enumtype.name}}] + def from_int( + cls, value: int, default: T.Optional[{{enumtype.name}}] = None + ) -> T.Optional[{{enumtype.name}}]: """ An alternative to "{{enumtype.name}}(value)" which will return the given default instead of raising a ValueError for unknown values. @@ -93,8 +85,7 @@ class {{enumtype.name}}(enum.Enum): return default @classmethod - def _get_hash_recursive(cls, parents): - # type: (T.List[T.Type]) -> int + def _get_hash_recursive(cls, parents: T.List[T.Type]) -> int: if cls in parents: return 0 tmphash = ({{enumtype.hash.hex_no_padding()}}) & 0xffffffffffffffff @@ -102,6 +93,5 @@ class {{enumtype.name}}(enum.Enum): return tmphash @classmethod - def _get_packed_fingerprint(cls): - # type: () -> bytes + def _get_packed_fingerprint(cls) -> bytes: return struct.pack(">Q", cls._get_hash_recursive([])) diff --git a/third_party/skymarshal/skymarshal/templates/python_enum_default_wrapper.py.template b/third_party/skymarshal/skymarshal/templates/python_enum_default_wrapper.py.template index 926ca9524..1aa85f76b 100644 --- a/third_party/skymarshal/skymarshal/templates/python_enum_default_wrapper.py.template +++ b/third_party/skymarshal/skymarshal/templates/python_enum_default_wrapper.py.template @@ -8,6 +8,8 @@ # isort: off # mypy: disallow-untyped-defs +from __future__ import annotations + import typing as T {% include "./python_enum.py.template" %} diff --git a/third_party/skymarshal/skymarshal/templates/python_struct.py.template b/third_party/skymarshal/skymarshal/templates/python_struct.py.template index bef6eef70..0c720e163 100644 --- a/third_party/skymarshal/skymarshal/templates/python_struct.py.template +++ b/third_party/skymarshal/skymarshal/templates/python_struct.py.template @@ -40,7 +40,7 @@ class {{ lcmtype.name }}(object): {% for member, _, init_val, type_hint in lcmtype.member_initializers() %} {{ member.name }}: {{ type_hint }}, {% endfor %} - ) -> "{{ lcmtype.name }}": + ) -> {{ lcmtype.name }}: return {{ lcmtype.name }}( {% for member, _, _, _ in lcmtype.member_initializers() %} {{ member.name }}={{ member.name }}, @@ -57,7 +57,7 @@ class {{ lcmtype.name }}(object): ) @classmethod - def _default(cls) -> "{{ lcmtype.name }}": + def _default(cls) -> {{ lcmtype.name }}: return cls() def __repr__(self) -> str: @@ -101,7 +101,7 @@ class {{ lcmtype.name }}(object): {{ lcmtype.encode_members(2) }} @staticmethod - def decode(data: T.Union[bytes, T.BinaryIO]) -> "{{ lcmtype.name }}": + def decode(data: T.Union[bytes, T.BinaryIO]) -> {{ lcmtype.name }}: # NOTE(eric): This function can technically accept either a BinaryIO or # anything that supports the C++ Buffer Protocol, # which is unspecifiable in type hints. @@ -117,7 +117,7 @@ class {{ lcmtype.name }}(object): return {{ lcmtype.name }}._decode_one(buf) @staticmethod - def _decode_one(buf: T.BinaryIO) -> "{{ lcmtype.name }}": + def _decode_one(buf: T.BinaryIO) -> {{ lcmtype.name }}: self = {{ lcmtype.name }}(_skip_initialize=True) {% if lcmtype.members %} {{ lcmtype.decode_members(2) }} @@ -142,7 +142,7 @@ class {{ lcmtype.name }}(object): {{ lcmtype.name }}._packed_fingerprint = struct.pack(">Q", {{ lcmtype.name }}._get_hash_recursive([])) return {{ lcmtype.name }}._packed_fingerprint - def deepcopy(self, **kwargs: T.Any) -> "{{ lcmtype.name }}": + def deepcopy(self, **kwargs: T.Any) -> {{ lcmtype.name }}: """ Deep copy of this LCM type diff --git a/third_party/skymarshal/skymarshal/templates/python_struct_default_wrapper.py.template b/third_party/skymarshal/skymarshal/templates/python_struct_default_wrapper.py.template index 8b354af2f..0bd7e1382 100644 --- a/third_party/skymarshal/skymarshal/templates/python_struct_default_wrapper.py.template +++ b/third_party/skymarshal/skymarshal/templates/python_struct_default_wrapper.py.template @@ -8,6 +8,8 @@ # From Source File: {{ lcmtype.struct.source_file }} {% endif %} +from __future__ import annotations + import copy import typing as T