-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Closed
Labels
featureIs an improvement or enhancementIs an improvement or enhancementgood first issueGood for newcomersGood for newcomershelp wantedOpen to be worked onOpen to be worked onlet's do it!approved to implementapproved to implementrefactorwon't fixThis will not be worked onThis will not be worked on
Description
🚀 Feature
Create null values for enums instead of using None. For example, utilities.enums.DistributedType should have a DistributedTypes.None enum value in addition to existing enum values.
Motivation
Python builtin None is hard to track, and I think it is always a good practice to have default null values for enums in compensation for the lack of null safety of Python. It is especially beneficial when a variable holding a type of enum will be None, which is the case for DistributedType in trainer.connectors.accelerator_connector.
Pitch
Define null values for enums, we can:
- keep track of when a variable of a enum type will be
None, facilitating code analysis - remind code collaborators of the possibility of being None when using an enum type
- (If we practice this broadly, we can at least) ensure code collaborators that a variable holding a value of a enum type will always valid(i.e. not literally
None) - "prevent"
Null pointer exception/None does not have method/attributeerror.
Additional context
When fixing #5966 in #5970, I have to take special care of None of self._distrib_type, which is a bit annoying.
Metadata
Metadata
Assignees
Labels
featureIs an improvement or enhancementIs an improvement or enhancementgood first issueGood for newcomersGood for newcomershelp wantedOpen to be worked onOpen to be worked onlet's do it!approved to implementapproved to implementrefactorwon't fixThis will not be worked onThis will not be worked on