You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@illicitonion left some very useful comments on #7226, one specifically asking why enums have defaults: #7226 (review). This led me to immediately realize that all of the complexity of the argument manipulation with *args, **kwargs in the .create() classmethod mentioned in #7226 (comment) was due to trying to support default values "hygienically", and the only thing that really needed a default value was Platform:
which really should only expose the current os name as the default value. The default value part was also maybe useful for registering enums as options directly, but we've now laid out how we want to do that in #7233. This ticket covers:
Remove any concept of enums having a default value, which should also allow us to turn the factory method into def create(value): without any complicated argument specs.
Expose an @memoized_classproperty as Platform.current and convert all usages of its .create() method with no args (all of them) to use that instead.
### Problem
Resolves#7232, resolves#7248, and addresses #7249 (comment).
### Solution
- Remove enum defaults and the `.create()` method with complicated argument handling.
- Allow enums to be `==` compared as long as they're the same type.
- Allow accessing enum instances with class attributes.
### Result
enums are nicer!
@illicitonion left some very useful comments on #7226, one specifically asking why
enum
s have defaults: #7226 (review). This led me to immediately realize that all of the complexity of the argument manipulation with*args, **kwargs
in the.create()
classmethod mentioned in #7226 (comment) was due to trying to support default values "hygienically", and the only thing that really needed a default value wasPlatform
:pants/src/python/pants/backend/native/config/environment.py
Lines 17 to 19 in 1ece461
def create(value):
without any complicated argument specs.@memoized_classproperty
asPlatform.current
and convert all usages of its.create()
method with no args (all of them) to use that instead..value
as per Canonicalize enum pattern matching for execution strategy, platform, and elsewhere #7226 (comment). Also, deprecate thefield_name
argument and remove all such usages in the pants repo.getattr
calls are all necessary and/or if the logic can be documented more as per Canonicalize enum pattern matching for execution strategy, platform, and elsewhere #7226 (comment).The text was updated successfully, but these errors were encountered: