@@ -945,9 +945,9 @@ class ExcelWriter(metaclass=abc.ABCMeta):
945945 # - Mandatory
946946 # - ``write_cells(self, cells, sheet_name=None, startrow=0, startcol=0)``
947947 # --> called to write additional DataFrames to disk
948- # - ``supported_extensions `` (tuple of supported extensions), used to
948+ # - ``_supported_extensions `` (tuple of supported extensions), used to
949949 # check that engine supports the given extension.
950- # - ``engine `` - string that gives the engine name. Necessary to
950+ # - ``_engine `` - string that gives the engine name. Necessary to
951951 # instantiate class directly and bypass ``ExcelWriterMeta`` engine
952952 # lookup.
953953 # - ``save(self)`` --> called to save file to disk
@@ -961,6 +961,10 @@ class ExcelWriter(metaclass=abc.ABCMeta):
961961 # You also need to register the class with ``register_writer()``.
962962 # Technically, ExcelWriter implementations don't need to subclass
963963 # ExcelWriter.
964+
965+ _engine : str
966+ _supported_extensions : tuple [str , ...]
967+
964968 def __new__ (
965969 cls ,
966970 path : FilePath | WriteExcelBuffer | ExcelWriter ,
@@ -983,7 +987,6 @@ def __new__(
983987 )
984988
985989 # only switch class if generic(ExcelWriter)
986-
987990 if cls is ExcelWriter :
988991 if engine is None or (isinstance (engine , str ) and engine == "auto" ):
989992 if isinstance (path , str ):
@@ -1027,16 +1030,14 @@ def __new__(
10271030 _path = None
10281031
10291032 @property
1030- @abc .abstractmethod
1031- def supported_extensions (self ) -> tuple [str , ...] | list [str ]:
1033+ def supported_extensions (self ) -> tuple [str , ...]:
10321034 """Extensions that writer engine supports."""
1033- pass
1035+ return self . _supported_extensions
10341036
10351037 @property
1036- @abc .abstractmethod
10371038 def engine (self ) -> str :
10381039 """Name of engine."""
1039- pass
1040+ return self . _engine
10401041
10411042 @property
10421043 @abc .abstractmethod
@@ -1292,12 +1293,7 @@ def check_extension(cls, ext: str) -> Literal[True]:
12921293 """
12931294 if ext .startswith ("." ):
12941295 ext = ext [1 :]
1295- # error: "Callable[[ExcelWriter], Any]" has no attribute "__iter__" (not
1296- # iterable)
1297- if not any (
1298- ext in extension
1299- for extension in cls .supported_extensions # type: ignore[attr-defined]
1300- ):
1296+ if not any (ext in extension for extension in cls ._supported_extensions ):
13011297 raise ValueError (f"Invalid extension for engine '{ cls .engine } ': '{ ext } '" )
13021298 else :
13031299 return True
0 commit comments