Skip to content

CurationWidget uses double-underscore names for internal methods that should be single underscore #624

Description

@aymuos15

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions