Skip to content

Commit

Permalink
cleansup some rust deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
rudolfix committed Dec 28, 2024
1 parent f93c927 commit d29dee6
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
target: x86_64
- os: macos
target: aarch64
interpreter: 3.9 3.10 3.11 3.12 3.13 pypy3.8 pypy3.9 pypy3.10
interpreter: 3.9 3.10 3.11 3.12 3.13 pypy3.9 pypy3.10



Expand Down
2 changes: 1 addition & 1 deletion rust/Cargo.lock

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

2 changes: 1 addition & 1 deletion rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "_pendulum"
version = "3.0.0"
version = "3.0.1"
edition = "2021"

[lib]
Expand Down
8 changes: 4 additions & 4 deletions rust/src/python/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl PartialOrd for DateTimeInfo<'_> {
pub fn get_tz_name<'py>(dt: &Bound<'py, PyAny>) -> PyResult<String> {
// let tz: &str = "";

if !PyDateTime::is_type_of_bound(dt) {
if !PyDateTime::is_type_of(dt) {
return Ok(String::new());
}

Expand Down Expand Up @@ -107,7 +107,7 @@ pub fn get_tz_name<'py>(dt: &Bound<'py, PyAny>) -> PyResult<String> {
}

pub fn get_offset(dt: &Bound<PyAny>) -> PyResult<i32> {
if !PyDateTime::is_type_of_bound(dt) {
if !PyDateTime::is_type_of(dt) {
return Ok(0);
}

Expand Down Expand Up @@ -170,7 +170,7 @@ pub fn precise_diff<'py>(
total_seconds: 0,
tz: dt1_tz.as_str(),
offset: get_offset(dt1)?,
is_datetime: PyDateTime::is_type_of_bound(dt1),
is_datetime: PyDateTime::is_type_of(dt1),
};
let mut dtinfo2 = DateTimeInfo {
year: dt2.downcast::<PyDate>()?.get_year(),
Expand All @@ -183,7 +183,7 @@ pub fn precise_diff<'py>(
total_seconds: 0,
tz: dt2_tz.as_str(),
offset: get_offset(dt2)?,
is_datetime: PyDateTime::is_exact_type_of_bound(dt2),
is_datetime: PyDateTime::is_exact_type_of(dt2),
};
let in_same_tz: bool = dtinfo1.tz == dtinfo2.tz && !dtinfo1.tz.is_empty();
let mut total_days = helpers::day_number(dtinfo2.year, dtinfo2.month as u8, dtinfo2.day as u8)
Expand Down
11 changes: 6 additions & 5 deletions rust/src/python/parsing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use pyo3::types::PyTime;
use crate::parsing::Parser;
use crate::python::types::{Duration, FixedTimezone};

#[allow(deprecated)]
#[pyfunction]
pub fn parse_iso8601(py: Python, input: &str) -> PyResult<PyObject> {
let parsed = Parser::new(input).parse();
Expand All @@ -16,7 +17,7 @@ pub fn parse_iso8601(py: Python, input: &str) -> PyResult<PyObject> {
(Some(datetime), None, None) => match (datetime.has_date, datetime.has_time) {
(true, true) => match datetime.offset {
Some(offset) => {
let dt = PyDateTime::new_bound(
let dt = PyDateTime::new(
py,
datetime.year as i32,
datetime.month as u8,
Expand All @@ -35,7 +36,7 @@ pub fn parse_iso8601(py: Python, input: &str) -> PyResult<PyObject> {
Ok(dt.to_object(py))
}
None => {
let dt = PyDateTime::new_bound(
let dt = PyDateTime::new(
py,
datetime.year as i32,
datetime.month as u8,
Expand All @@ -51,7 +52,7 @@ pub fn parse_iso8601(py: Python, input: &str) -> PyResult<PyObject> {
}
},
(true, false) => {
let dt = PyDate::new_bound(
let dt = PyDate::new(
py,
datetime.year as i32,
datetime.month as u8,
Expand All @@ -62,7 +63,7 @@ pub fn parse_iso8601(py: Python, input: &str) -> PyResult<PyObject> {
}
(false, true) => match datetime.offset {
Some(offset) => {
let dt = PyTime::new_bound(
let dt = PyTime::new(
py,
datetime.hour as u8,
datetime.minute as u8,
Expand All @@ -78,7 +79,7 @@ pub fn parse_iso8601(py: Python, input: &str) -> PyResult<PyObject> {
Ok(dt.to_object(py))
}
None => {
let dt = PyTime::new_bound(
let dt = PyTime::new(
py,
datetime.hour as u8,
datetime.minute as u8,
Expand Down
4 changes: 2 additions & 2 deletions rust/src/python/types/timezone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ impl FixedTimezone {
py: Python<'p>,
_dt: &Bound<'p, PyAny>,
) -> Result<pyo3::Bound<'p, PyDelta>, PyErr> {
PyDelta::new_bound(py, 0, self.offset, 0, true)
PyDelta::new(py, 0, self.offset, 0, true)
}

fn tzname(&self, _dt: &Bound<PyAny>) -> String {
Expand All @@ -33,7 +33,7 @@ impl FixedTimezone {
py: Python<'p>,
_dt: &Bound<'p, PyAny>,
) -> Result<pyo3::Bound<'p, PyDelta>, PyErr> {
PyDelta::new_bound(py, 0, 0, 0, true)
PyDelta::new(py, 0, 0, 0, true)
}

fn __repr__(&self) -> String {
Expand Down

0 comments on commit d29dee6

Please sign in to comment.