Skip to content

Commit

Permalink
chlog & warning
Browse files Browse the repository at this point in the history
  • Loading branch information
Borda committed Feb 7, 2023
1 parent f84c443 commit 157c362
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 23 deletions.
21 changes: 2 additions & 19 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

-
- Extended `StrEnum.from_str` with optional raising ValueError ([#99](https://github.com/Lightning-AI/utilities/pull/99))


### Changed
Expand All @@ -20,7 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

-
- fixed `StrEnum.from_str` with source as key ([#99](https://github.com/Lightning-AI/utilities/pull/99))


## [0.6.0] - 2023-01-23
Expand All @@ -40,23 +40,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- CI: Checking schem in both yaml & yml + verbose ([#84](https://github.com/Lightning-AI/utilities/pull/84))


## [UnReleased] - 2023-MM-DD

### Added

-


### Changed

- CI/docs: allow passing env. variables ([#96](https://github.com/Lightning-AI/utilities/pull/96))


### Fixed

-


## [0.5.0] - 2022-12-21

### Added
Expand Down
6 changes: 2 additions & 4 deletions src/lightning_utilities/core/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# http://www.apache.org/licenses/LICENSE-2.0
#
import warnings
from enum import Enum
from typing import Optional

Expand Down Expand Up @@ -45,9 +46,6 @@ def from_str(cls, value: str, source: Literal["key", "value", "any"] = "key", st
... t1 = "T-1"
... t2 = "T-2"
>>> MySE.from_str("t-1", source="key")
Traceback (most recent call last):
...
UserWarning: Invalid string: expected one of ['t1', 't2'], but got t-1.
>>> MySE.from_str("t-2", source="value")
<MySE.t2: 'T-2'>
>>> MySE.from_str("t-3", source="any", strict=True)
Expand All @@ -69,7 +67,7 @@ def from_str(cls, value: str, source: Literal["key", "value", "any"] = "key", st
if enum_val == value:
return cls[enum_key]

raise UserWarning(f"Invalid string: expected one of {allowed}, but got {value}.")
warnings.warn(UserWarning(f"Invalid string: expected one of {allowed}, but got {value}."))

@classmethod
def _allowed_matches(cls, source) -> list:
Expand Down

0 comments on commit 157c362

Please sign in to comment.