diff --git a/Makefile b/Makefile index b15183a1..468cd9a1 100644 --- a/Makefile +++ b/Makefile @@ -54,68 +54,10 @@ tox: lint-rust: - cargo fmt --version cargo fmt --all -- --check - cargo clippy --version - cargo clippy --tests -- \ - -D warnings \ - -W clippy::pedantic \ - -W clippy::dbg_macro \ - -W clippy::print_stdout \ - -A clippy::cast-possible-truncation \ - -A clippy::cast-possible-wrap \ - -A clippy::cast-precision-loss \ - -A clippy::cast-sign-loss \ - -A clippy::doc-markdown \ - -A clippy::float-cmp \ - -A clippy::fn-params-excessive-bools \ - -A clippy::if-not-else \ - -A clippy::manual-let-else \ - -A clippy::match-bool \ - -A clippy::match-same-arms \ - -A clippy::missing-errors-doc \ - -A clippy::missing-panics-doc \ - -A clippy::module-name-repetitions \ - -A clippy::must-use-candidate \ - -A clippy::needless-pass-by-value \ - -A clippy::similar-names \ - -A clippy::single-match-else \ - -A clippy::struct-excessive-bools \ - -A clippy::too-many-lines \ - -A clippy::unnecessary-wraps \ - -A clippy::unused-self \ - -A clippy::used-underscore-binding + cargo clippy --tests -- -D warnings format-rust: - cargo fmt --version cargo fmt --all - cargo clippy --version - cargo clippy --tests --fix --allow-dirty -- \ - -D warnings \ - -W clippy::pedantic \ - -W clippy::dbg_macro \ - -W clippy::print_stdout \ - -A clippy::cast-possible-truncation \ - -A clippy::cast-possible-wrap \ - -A clippy::cast-precision-loss \ - -A clippy::cast-sign-loss \ - -A clippy::doc-markdown \ - -A clippy::float-cmp \ - -A clippy::fn-params-excessive-bools \ - -A clippy::if-not-else \ - -A clippy::manual-let-else \ - -A clippy::match-bool \ - -A clippy::match-same-arms \ - -A clippy::missing-errors-doc \ - -A clippy::missing-panics-doc \ - -A clippy::module-name-repetitions \ - -A clippy::must-use-candidate \ - -A clippy::needless-pass-by-value \ - -A clippy::similar-names \ - -A clippy::single-match-else \ - -A clippy::struct-excessive-bools \ - -A clippy::too-many-lines \ - -A clippy::unnecessary-wraps \ - -A clippy::unused-self \ - -A clippy::used-underscore-binding + cargo clippy --tests --fix --allow-dirty -- -D warnings diff --git a/_pendulum.pyi b/_pendulum.pyi index 02520a14..74d7d830 100644 --- a/_pendulum.pyi +++ b/_pendulum.pyi @@ -37,5 +37,4 @@ def local_time( unix_time: int, utc_offset: int, microseconds: int ) -> tuple[int, int, int, int, int, int, int]: ... def precise_diff(d1: datetime | date, d2: datetime | date) -> PreciseDiff: ... -def timestamp(dt: datetime) -> int: ... def week_day(year: int, month: int, day: int) -> int: ... diff --git a/build.py b/build.py index 4ff12214..60d3c4ba 100644 --- a/build.py +++ b/build.py @@ -25,6 +25,9 @@ def _build(): maturin("build", "-r", *cargo_args) + # We won't use the wheel built by maturin directly since + # we want Poetry to build it but we need to retrieve the + # compiled extensions from the maturin wheel. wheel = list(wheels_dir.glob("*.whl"))[0] with zipfile.ZipFile(wheel.as_posix()) as whl: whl.extractall(wheels_dir.as_posix()) diff --git a/pendulum/_helpers.py b/pendulum/_helpers.py index 4dd4c726..1b586d31 100644 --- a/pendulum/_helpers.py +++ b/pendulum/_helpers.py @@ -84,28 +84,6 @@ def days_in_year(year: int) -> int: return DAYS_PER_N_YEAR -def timestamp(dt: datetime.datetime) -> int: - year = dt.year - - result = (year - 1970) * 365 + MONTHS_OFFSETS[0][dt.month] - result += (year - 1968) // 4 - result -= (year - 1900) // 100 - result += (year - 1600) // 400 - - if is_leap(year) and dt.month < 3: - result -= 1 - - result += dt.day - 1 - result *= 24 - result += dt.hour - result *= 60 - result += dt.minute - result *= 60 - result += dt.second - - return result - - def local_time( unix_time: int, utc_offset: int, microseconds: int ) -> tuple[int, int, int, int, int, int, int]: diff --git a/pendulum/parser.py b/pendulum/parser.py index 66e33ea1..2cb5ef95 100644 --- a/pendulum/parser.py +++ b/pendulum/parser.py @@ -18,9 +18,9 @@ from pendulum.time import Time try: - from _pendulum import Duration as CDuration + from _pendulum import Duration as RustDuration except ImportError: - CDuration = None # type: ignore[assignment,misc] + RustDuration = None # type: ignore[assignment,misc] def parse(text: str, **options: t.Any) -> Date | Time | DateTime | Duration: @@ -113,7 +113,7 @@ def _parse(text: str, **options: t.Any) -> Date | DateTime | Time | Duration | I if isinstance(parsed, Duration): return parsed - if CDuration and isinstance(parsed, CDuration): # type: ignore[truthy-function] + if RustDuration is not None and isinstance(parsed, RustDuration): return pendulum.duration( years=parsed.years, months=parsed.months, diff --git a/pyproject.toml b/pyproject.toml index e0382f98..5fd519a8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,9 +17,6 @@ packages = [ include = [ { path = "meson.build", format = "sdist" }, { path = "pendulum/py.typed" }, - # C extensions must be included in the wheel distributions - { path = "pendulum/_extensions/*.so", format = "wheel" }, - { path = "pendulum/_extensions/*.pyd", format = "wheel" }, # Typing stubs { path = "*.pyi"}, # Rust source @@ -224,5 +221,5 @@ omit = [ ] [build-system] -requires = ["poetry-core>=1.1.0a6", "maturin>=1,<2"] +requires = ["poetry-core>=1.6.1", "maturin>=1,<2"] build-backend = "poetry.core.masonry.api"