@@ -406,23 +406,29 @@ class AccessorEntryPointLoader: # is this a good name for the class?
406406 @classmethod
407407 def load (cls ) -> None :
408408 """loads and registers accessors defined by 'pandas_accessor'."""
409- packages = entry_points (group = cls .ENTRY_POINT_GROUP )
410- unique_packages_names : set [str ] = set ()
411-
412- for package in packages :
413- # Verifies duplicated package names
414- if package .name in unique_packages_names :
409+ accessors = entry_points (group = cls .ENTRY_POINT_GROUP )
410+ unique_accessors_names : set [str ] = set ()
411+
412+ for accessor in accessors :
413+ # Verifies duplicated accessor names
414+ if accessor .name in unique_accessors_names :
415+ try :
416+ pkg_name : str = accessor .dist .name
417+ except Exception :
418+ pkg_name = "unknown"
415419 warnings .warn (
416- "Warning: you have two packages with the same name:"
417- f" '{ package .name } '\n "
418- "Uninstall the package you don't want to use "
419- "in order to remove this warning.\n " ,
420+ "Warning: you have two accessors with the same name:"
421+ f" '{ accessor .name } ' has already been registered"
422+ f" by the package '{ pkg_name } '. So the '{ accessor .name } ' "
423+ f"provided by the package '{ pkg_name } ' is not "
424+ f"being used. Uninstall the package you don't want"
425+ "to use if you want to get rid of this warning.\n " ,
420426 UserWarning ,
421427 stacklevel = 2 ,
422428 )
423429
424430 else :
425- unique_packages_names .add (package .name )
431+ unique_accessors_names .add (accessor .name )
426432
427433 def make_property (ep ):
428434 def accessor (self ) -> Any :
@@ -431,4 +437,5 @@ def accessor(self) -> Any:
431437
432438 return accessor
433439
434- register_dataframe_accessor (package .name )(make_property (package ))
440+ # _register_accessor()
441+ register_dataframe_accessor (accessor .name )(make_property (accessor ))
0 commit comments