Skip to content

Commit d29dee6

Browse files
committed
cleansup some rust deprecations
1 parent f93c927 commit d29dee6

File tree

6 files changed

+15
-14
lines changed

6 files changed

+15
-14
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ jobs:
7070
target: x86_64
7171
- os: macos
7272
target: aarch64
73-
interpreter: 3.9 3.10 3.11 3.12 3.13 pypy3.8 pypy3.9 pypy3.10
73+
interpreter: 3.9 3.10 3.11 3.12 3.13 pypy3.9 pypy3.10
7474

7575

7676

rust/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "_pendulum"
3-
version = "3.0.0"
3+
version = "3.0.1"
44
edition = "2021"
55

66
[lib]

rust/src/python/helpers.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ impl PartialOrd for DateTimeInfo<'_> {
7676
pub fn get_tz_name<'py>(dt: &Bound<'py, PyAny>) -> PyResult<String> {
7777
// let tz: &str = "";
7878

79-
if !PyDateTime::is_type_of_bound(dt) {
79+
if !PyDateTime::is_type_of(dt) {
8080
return Ok(String::new());
8181
}
8282

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

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

@@ -170,7 +170,7 @@ pub fn precise_diff<'py>(
170170
total_seconds: 0,
171171
tz: dt1_tz.as_str(),
172172
offset: get_offset(dt1)?,
173-
is_datetime: PyDateTime::is_type_of_bound(dt1),
173+
is_datetime: PyDateTime::is_type_of(dt1),
174174
};
175175
let mut dtinfo2 = DateTimeInfo {
176176
year: dt2.downcast::<PyDate>()?.get_year(),
@@ -183,7 +183,7 @@ pub fn precise_diff<'py>(
183183
total_seconds: 0,
184184
tz: dt2_tz.as_str(),
185185
offset: get_offset(dt2)?,
186-
is_datetime: PyDateTime::is_exact_type_of_bound(dt2),
186+
is_datetime: PyDateTime::is_exact_type_of(dt2),
187187
};
188188
let in_same_tz: bool = dtinfo1.tz == dtinfo2.tz && !dtinfo1.tz.is_empty();
189189
let mut total_days = helpers::day_number(dtinfo2.year, dtinfo2.month as u8, dtinfo2.day as u8)

rust/src/python/parsing.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use pyo3::types::PyTime;
77
use crate::parsing::Parser;
88
use crate::python::types::{Duration, FixedTimezone};
99

10+
#[allow(deprecated)]
1011
#[pyfunction]
1112
pub fn parse_iso8601(py: Python, input: &str) -> PyResult<PyObject> {
1213
let parsed = Parser::new(input).parse();
@@ -16,7 +17,7 @@ pub fn parse_iso8601(py: Python, input: &str) -> PyResult<PyObject> {
1617
(Some(datetime), None, None) => match (datetime.has_date, datetime.has_time) {
1718
(true, true) => match datetime.offset {
1819
Some(offset) => {
19-
let dt = PyDateTime::new_bound(
20+
let dt = PyDateTime::new(
2021
py,
2122
datetime.year as i32,
2223
datetime.month as u8,
@@ -35,7 +36,7 @@ pub fn parse_iso8601(py: Python, input: &str) -> PyResult<PyObject> {
3536
Ok(dt.to_object(py))
3637
}
3738
None => {
38-
let dt = PyDateTime::new_bound(
39+
let dt = PyDateTime::new(
3940
py,
4041
datetime.year as i32,
4142
datetime.month as u8,
@@ -51,7 +52,7 @@ pub fn parse_iso8601(py: Python, input: &str) -> PyResult<PyObject> {
5152
}
5253
},
5354
(true, false) => {
54-
let dt = PyDate::new_bound(
55+
let dt = PyDate::new(
5556
py,
5657
datetime.year as i32,
5758
datetime.month as u8,
@@ -62,7 +63,7 @@ pub fn parse_iso8601(py: Python, input: &str) -> PyResult<PyObject> {
6263
}
6364
(false, true) => match datetime.offset {
6465
Some(offset) => {
65-
let dt = PyTime::new_bound(
66+
let dt = PyTime::new(
6667
py,
6768
datetime.hour as u8,
6869
datetime.minute as u8,
@@ -78,7 +79,7 @@ pub fn parse_iso8601(py: Python, input: &str) -> PyResult<PyObject> {
7879
Ok(dt.to_object(py))
7980
}
8081
None => {
81-
let dt = PyTime::new_bound(
82+
let dt = PyTime::new(
8283
py,
8384
datetime.hour as u8,
8485
datetime.minute as u8,

rust/src/python/types/timezone.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ impl FixedTimezone {
2121
py: Python<'p>,
2222
_dt: &Bound<'p, PyAny>,
2323
) -> Result<pyo3::Bound<'p, PyDelta>, PyErr> {
24-
PyDelta::new_bound(py, 0, self.offset, 0, true)
24+
PyDelta::new(py, 0, self.offset, 0, true)
2525
}
2626

2727
fn tzname(&self, _dt: &Bound<PyAny>) -> String {
@@ -33,7 +33,7 @@ impl FixedTimezone {
3333
py: Python<'p>,
3434
_dt: &Bound<'p, PyAny>,
3535
) -> Result<pyo3::Bound<'p, PyDelta>, PyErr> {
36-
PyDelta::new_bound(py, 0, 0, 0, true)
36+
PyDelta::new(py, 0, 0, 0, true)
3737
}
3838

3939
fn __repr__(&self) -> String {

0 commit comments

Comments
 (0)