Skip to content

Commit 95b7a5c

Browse files
committed
small improvements + fix pipeline
1 parent 1013934 commit 95b7a5c

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

pandas/core/accessor.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -466,19 +466,15 @@ def accessor_entry_point_loader() -> None:
466466
df.myplugin.do_something() # Calls MyPluginAccessor.do_something()
467467
"""
468468

469-
PD_OBJECTS_ENTRYPOINTS: list[str] = [
470-
"pandas.DataFrame.accessor",
471-
"pandas.Series.accessor",
472-
"pandas.Index.accessor",
473-
]
474-
475469
ACCESSOR_REGISTRY_FUNCTIONS: dict[str, Callable] = {
476470
"pandas.DataFrame.accessor": register_dataframe_accessor,
477471
"pandas.Series.accessor": register_series_accessor,
478472
"pandas.Index.accessor": register_index_accessor,
479473
}
480474

481-
for pd_obj_entrypoint in PD_OBJECTS_ENTRYPOINTS:
475+
pd_objects_entrypoints: list[str] = ACCESSOR_REGISTRY_FUNCTIONS.keys()
476+
477+
for pd_obj_entrypoint in pd_objects_entrypoints:
482478
accessors: EntryPoints = entry_points(group=pd_obj_entrypoint)
483479
accessor_package_dict: dict[str, str] = {}
484480

@@ -488,10 +484,9 @@ def accessor_entry_point_loader() -> None:
488484

489485
# Verifies duplicated accessor names
490486
if new_accessor.name in accessor_package_dict:
491-
loaded_pkg_name: str = accessor_package_dict.get(new_accessor.name)
492-
493-
if loaded_pkg_name is None:
494-
loaded_pkg_name: str = "Unknown"
487+
loaded_pkg_name: str = accessor_package_dict.get(
488+
new_accessor.name, "Unknown"
489+
)
495490

496491
warnings.warn(
497492
"Warning: you have two accessors with the same name:"

pandas/tests/test_plugins_entrypoint_loader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def load(self):
4343
return self._accessor_class
4444

4545
# Create a dictionary of MockEntryPoint instances
46-
group_map = {g: [] for g in PD_OBJECTS_ENTRYPOINTS}
46+
group_map: dict[str, list[MockEntryPoint]] = {g: [] for g in PD_OBJECTS_ENTRYPOINTS}
4747

4848
for ep_group, ep_properties in entry_points.items():
4949
for name, accessor_class, dist_name in ep_properties:

0 commit comments

Comments
 (0)