11"""Base Packager class."""
22
3+ from __future__ import annotations
4+
35import inspect
4- from pathlib import Path
56import sys
67import textwrap
8+ from pathlib import Path
79
810from skbase .base import BaseObject
911from skbase .utils .dependencies import _check_estimator_deps
1012
1113
1214class _BasePkg (BaseObject ):
13-
1415 _tags = {
1516 "python_dependencies" : None ,
1617 "python_version" : None ,
@@ -50,15 +51,11 @@ def serialize(self):
5051
5152 cls_str = cls_str .encode ("utf-8" )
5253 exec (f"import { compress_method } " )
53- compressed_str = eval (f"{ compress_method } .compress(cls_str)" )
54-
55- return compressed_str
54+ return eval (f"{ compress_method } .compress(cls_str)" )
5655
5756
5857def _has_source (obj ) -> bool :
59- """
60- Return True if inspect.getsource(obj) should succeed.
61- """
58+ """Return True if inspect.getsource(obj) should succeed."""
6259 module_name = getattr (obj , "__module__" , None )
6360 if not module_name or module_name not in sys .modules :
6461 return False
@@ -82,7 +79,7 @@ def class_to_source(cls) -> str:
8279 -------
8380 str : complete definition of cls, as str.
8481 Imports are not contained or serialized.
85- """ ""
82+ """ ""
8683
8784 # Fast path: class has retrievable source
8885 if _has_source (cls ):
@@ -111,7 +108,7 @@ def class_to_source(cls) -> str:
111108 lines .append (f" def { name } (self): ..." )
112109 body_added = True
113110 else :
114- lines .append (f" { name } = { repr ( value ) } " )
111+ lines .append (f" { name } = { value !r } " )
115112 body_added = True
116113
117114 if not body_added :
0 commit comments