Skip to content

Commit

Permalink
python: fix casing for enum variants in stub
Browse files Browse the repository at this point in the history
Fixes #69
  • Loading branch information
remi-dupre committed Feb 7, 2025
1 parent a08f742 commit 855da9d
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 27 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 1.0.3

### Python

- stub: fix variants casing for `State`

## 1.0.2

### Python
Expand Down
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "opening-hours"
version = "1.0.2"
version = "1.0.3"
authors = ["Rémi Dupré <remi@dupre.io>"]
license = "MIT OR Apache-2.0"
readme = "README.md"
Expand Down Expand Up @@ -34,9 +34,9 @@ disable-test-timeouts = []

[dependencies]
chrono = "0.4"
compact-calendar = { path = "compact-calendar", version = "1.0.2" }
compact-calendar = { path = "compact-calendar", version = "1.0.3" }
flate2 = "1.0"
opening-hours-syntax = { path = "opening-hours-syntax", version = "1.0.2" }
opening-hours-syntax = { path = "opening-hours-syntax", version = "1.0.3" }
sunrise-next = "1.2"

# Feature: log (default)
Expand All @@ -51,7 +51,7 @@ tzf-rs = { version = "0.4", default-features = false, optional = true }

[build-dependencies]
chrono = "0.4"
compact-calendar = { path = "compact-calendar", version = "1.0.2" }
compact-calendar = { path = "compact-calendar", version = "1.0.3" }
country-boundaries = { version = "1.2", optional = true }
flate2 = "1.0"
rustc_version = "0.4.0"
Expand Down
2 changes: 1 addition & 1 deletion compact-calendar/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "compact-calendar"
version = "1.0.2"
version = "1.0.3"
authors = ["Rémi Dupré <remi@dupre.io>"]
license = "MIT OR Apache-2.0"
readme = "README.md"
Expand Down
6 changes: 3 additions & 3 deletions opening-hours-py/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "opening-hours-py"
version = "1.0.2"
version = "1.0.3"
authors = ["Rémi Dupré <remi@dupre.io>"]
license = "MIT OR Apache-2.0"
readme = "README.md"
Expand All @@ -23,12 +23,12 @@ pyo3-stub-gen = "0.7"
[dependencies.opening-hours-rs]
package = "opening-hours"
path = ".."
version = "1.0.2"
version = "1.0.3"
features = ["log", "auto-country", "auto-timezone"]

[dependencies.opening-hours-syntax]
path = "../opening-hours-syntax"
version = "1.0.2"
version = "1.0.3"
features = ["log"]

[dependencies.pyo3]
Expand Down
21 changes: 11 additions & 10 deletions opening-hours-py/src/types/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,35 @@ use pyo3_stub_gen::derive::gen_stub_pyclass_enum;
use opening_hours_syntax::rules::RuleKind;

/// Specify the state of an opening hours interval.
#[allow(clippy::upper_case_acronyms)]
#[gen_stub_pyclass_enum]
#[pyclass(ord, eq, frozen, hash, str, rename_all = "UPPERCASE")]
#[pyclass(ord, eq, frozen, hash, str)]
#[derive(Hash, PartialOrd, Ord, PartialEq, Eq)]
pub enum State {
/// Currently open
Open,
OPEN,
/// Currently closed
Closed,
CLOSED,
/// May be open depending on context
Unknown,
UNKNOWN,
}

impl From<RuleKind> for State {
fn from(kind: RuleKind) -> Self {
match kind {
RuleKind::Open => Self::Open,
RuleKind::Closed => Self::Closed,
RuleKind::Unknown => Self::Unknown,
RuleKind::Open => Self::OPEN,
RuleKind::Closed => Self::CLOSED,
RuleKind::Unknown => Self::UNKNOWN,
}
}
}

impl std::fmt::Display for State {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
State::Open => write!(f, "open"),
State::Closed => write!(f, "closed"),
State::Unknown => write!(f, "unknown"),
State::OPEN => write!(f, "open"),
State::CLOSED => write!(f, "closed"),
State::UNKNOWN => write!(f, "unknown"),
}
}
}
2 changes: 1 addition & 1 deletion opening-hours-syntax/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "opening-hours-syntax"
version = "1.0.2"
version = "1.0.3"
authors = ["Rémi Dupré <remi@dupre.io>"]
license = "MIT OR Apache-2.0"
readme = "README.md"
Expand Down
6 changes: 3 additions & 3 deletions opening_hours.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,9 @@ class State(Enum):
Specify the state of an opening hours interval.
"""

Open = auto()
Closed = auto()
Unknown = auto()
OPEN = auto()
CLOSED = auto()
UNKNOWN = auto()

def validate(oh: builtins.str) -> builtins.bool:
r"""
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ dynamic = ["version"]

[tool.poetry]
name = "opening_hours_py"
version = "1.0.2"
version = "1.0.3"
description = "A parser for the opening_hours fields from OpenStreetMap."
authors = ["Rémi Dupré <remi@dupre.io>"]
package-mode = false
Expand Down

0 comments on commit 855da9d

Please sign in to comment.