Describe the problem
Five internal methods on CurationWidget in cellfinder/napari/curation.py are named with a leading double underscore:
__prep_directories_for_save
__delete_existing_saved_training_data
__extract_cubes
__finish_save
__save_yaml_file
A leading __ triggers Python name mangling: the identifier is rewritten to _CurationWidget__name at compile time. Per the language reference and tutorial, mangling exists specifically to avoid name clashes with subclasses, not to mark a method as internal. The convention for "non-public, treat as internal" is a single leading underscore. These methods are plain internal helpers and are not designed to resist subclass overrides.
Expected
Internal helper methods use a single leading underscore, consistent with the rest of the codebase.
Additional context
This is the established style everywhere else in the repo. Repo-wide there are 40 single-underscore internal methods across 12 files versus these 5 double-underscore-as-internal methods, all confined to curation.py. The only other dunder method defs in the codebase are genuine Python protocol methods (__init__, __call__, __len__, __getitem__, __iter__, __getstate__), which are correct. curation.py is itself mixed: it already has single-underscore helpers like _add_training_data_layers alongside the five dunders.
This was raised by @alessandrofelder in review of PR #621, where the new __finish_save method followed the file's existing dunder style for consistency. The other four predate it.
Proposed fix
Rename the five methods to single underscore and update their call sites within CurationWidget:
| Current |
Renamed to |
__prep_directories_for_save |
_prep_directories_for_save |
__delete_existing_saved_training_data |
_delete_existing_saved_training_data |
__extract_cubes |
_extract_cubes |
__finish_save |
_finish_save |
__save_yaml_file |
_save_yaml_file |
All references are internal to the class, so no public API changes.
Describe the problem
Five internal methods on
CurationWidgetincellfinder/napari/curation.pyare named with a leading double underscore:__prep_directories_for_save__delete_existing_saved_training_data__extract_cubes__finish_save__save_yaml_fileA leading
__triggers Python name mangling: the identifier is rewritten to_CurationWidget__nameat compile time. Per the language reference and tutorial, mangling exists specifically to avoid name clashes with subclasses, not to mark a method as internal. The convention for "non-public, treat as internal" is a single leading underscore. These methods are plain internal helpers and are not designed to resist subclass overrides.Expected
Internal helper methods use a single leading underscore, consistent with the rest of the codebase.
Additional context
This is the established style everywhere else in the repo. Repo-wide there are 40 single-underscore internal methods across 12 files versus these 5 double-underscore-as-internal methods, all confined to
curation.py. The only other dunder method defs in the codebase are genuine Python protocol methods (__init__,__call__,__len__,__getitem__,__iter__,__getstate__), which are correct.curation.pyis itself mixed: it already has single-underscore helpers like_add_training_data_layersalongside the five dunders.This was raised by @alessandrofelder in review of PR #621, where the new
__finish_savemethod followed the file's existing dunder style for consistency. The other four predate it.Proposed fix
Rename the five methods to single underscore and update their call sites within
CurationWidget:__prep_directories_for_save_prep_directories_for_save__delete_existing_saved_training_data_delete_existing_saved_training_data__extract_cubes_extract_cubes__finish_save_finish_save__save_yaml_file_save_yaml_fileAll references are internal to the class, so no public API changes.