Skip to content

Commit eca20fe

Browse files
committed
Merge branch 'main' into remove-header-parsing
2 parents 80c747d + 3bc5caa commit eca20fe

File tree

10 files changed

+49
-40
lines changed

10 files changed

+49
-40
lines changed

src/class/gc.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,16 @@ use std::os::raw::{c_int, c_void};
1010
pub struct PyTraverseError(c_int);
1111

1212
/// GC support
13+
#[allow(clippy::upper_case_acronyms)]
1314
pub trait PyGCProtocol<'p>: PyClass {
1415
fn __traverse__(&'p self, visit: PyVisit) -> Result<(), PyTraverseError>;
1516
fn __clear__(&'p mut self);
1617
}
1718

19+
#[allow(clippy::upper_case_acronyms)]
1820
pub trait PyGCTraverseProtocol<'p>: PyGCProtocol<'p> {}
21+
22+
#[allow(clippy::upper_case_acronyms)]
1923
pub trait PyGCClearProtocol<'p>: PyGCProtocol<'p> {}
2024

2125
#[doc(hidden)]

src/class/impl_.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ methods_trait!(PyMethods, py_methods);
140140

141141
macro_rules! slots_trait {
142142
($name:ident, $function_name: ident) => {
143+
#[allow(clippy::upper_case_acronyms)]
143144
pub trait $name<T> {
144145
fn $function_name(self) -> &'static [ffi::PyType_Slot];
145146
}

src/class/macros.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ macro_rules! py_binary_self_func {
162162
$crate::callback_body!(py, {
163163
let slf_ = py.from_borrowed_ptr::<$crate::PyCell<T>>(slf);
164164
let arg = py.from_borrowed_ptr::<$crate::PyAny>(arg);
165+
#[allow(clippy::needless_question_mark)]
165166
call_operator_mut!(py, slf_, $f, arg).convert(py)?;
166167
ffi::Py_INCREF(slf);
167168
Ok::<_, $crate::err::PyErr>(slf)

src/class/number.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,11 +446,13 @@ pub trait PyNumberRPowProtocol<'p>: PyNumberProtocol<'p> {
446446
type Result: IntoPyCallbackOutput<PyObject>;
447447
}
448448

449+
#[allow(clippy::upper_case_acronyms)]
449450
pub trait PyNumberRLShiftProtocol<'p>: PyNumberProtocol<'p> {
450451
type Other: FromPyObject<'p>;
451452
type Result: IntoPyCallbackOutput<PyObject>;
452453
}
453454

455+
#[allow(clippy::upper_case_acronyms)]
454456
pub trait PyNumberRRShiftProtocol<'p>: PyNumberProtocol<'p> {
455457
type Other: FromPyObject<'p>;
456458
type Result: IntoPyCallbackOutput<PyObject>;
@@ -516,11 +518,13 @@ pub trait PyNumberIPowProtocol<'p>: PyNumberProtocol<'p> {
516518
type Result: IntoPyCallbackOutput<()>;
517519
}
518520

521+
#[allow(clippy::upper_case_acronyms)]
519522
pub trait PyNumberILShiftProtocol<'p>: PyNumberProtocol<'p> {
520523
type Other: FromPyObject<'p>;
521524
type Result: IntoPyCallbackOutput<()>;
522525
}
523526

527+
#[allow(clippy::upper_case_acronyms)]
524528
pub trait PyNumberIRShiftProtocol<'p>: PyNumberProtocol<'p> {
525529
type Other: FromPyObject<'p>;
526530
type Result: IntoPyCallbackOutput<()>;
@@ -738,6 +742,7 @@ where
738742
crate::callback_body!(py, {
739743
let slf_cell = py.from_borrowed_ptr::<crate::PyCell<T>>(slf);
740744
let other = py.from_borrowed_ptr::<crate::PyAny>(other);
745+
#[allow(clippy::needless_question_mark)]
741746
call_operator_mut!(py, slf_cell, __ipow__, other).convert(py)?;
742747
ffi::Py_INCREF(slf);
743748
Ok::<_, PyErr>(slf)

src/exceptions.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ macro_rules! create_exception_type_object {
197197

198198
macro_rules! impl_native_exception (
199199
($name:ident, $exc_name:ident, $layout:path) => (
200+
#[allow(clippy::upper_case_acronyms)]
200201
pub struct $name($crate::PyAny);
201202

202203
$crate::impl_exception_boilerplate!($name);

src/ffi/datetime.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -365,14 +365,12 @@ pub struct PyDateTime_CAPI {
365365
pub TZInfoType: *mut PyTypeObject,
366366
#[cfg(all(Py_3_7, not(PyPy)))]
367367
pub TimeZone_UTC: *mut PyObject,
368-
#[cfg_attr(PyPy, link_name = "_PyPyDate_FromDate")]
369368
pub Date_FromDate: unsafe extern "C" fn(
370369
year: c_int,
371370
month: c_int,
372371
day: c_int,
373372
cls: *mut PyTypeObject,
374373
) -> *mut PyObject,
375-
#[cfg_attr(PyPy, link_name = "_PyPyDateTime_FromDateAndTime")]
376374
pub DateTime_FromDateAndTime: unsafe extern "C" fn(
377375
year: c_int,
378376
month: c_int,
@@ -384,7 +382,6 @@ pub struct PyDateTime_CAPI {
384382
tzinfo: *mut PyObject,
385383
cls: *mut PyTypeObject,
386384
) -> *mut PyObject,
387-
#[cfg_attr(PyPy, link_name = "_PyPyTime_FromTime")]
388385
pub Time_FromTime: unsafe extern "C" fn(
389386
hour: c_int,
390387
minute: c_int,
@@ -393,7 +390,6 @@ pub struct PyDateTime_CAPI {
393390
tzinfo: *mut PyObject,
394391
cls: *mut PyTypeObject,
395392
) -> *mut PyObject,
396-
#[cfg_attr(PyPy, link_name = "_PyPyDelta_FromDelta")]
397393
pub Delta_FromDelta: unsafe extern "C" fn(
398394
days: c_int,
399395
seconds: c_int,

src/gil.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ where
193193
/// let py = gil_guard.python();
194194
/// } // GIL is released when gil_guard is dropped
195195
/// ```
196+
#[allow(clippy::upper_case_acronyms)]
196197
#[must_use]
197198
pub struct GILGuard {
198199
gstate: ffi::PyGILState_STATE,
@@ -367,6 +368,7 @@ unsafe impl Sync for ReferencePool {}
367368
static POOL: ReferencePool = ReferencePool::new();
368369

369370
/// A RAII pool which PyO3 uses to store owned Python references.
371+
#[allow(clippy::upper_case_acronyms)]
370372
pub struct GILPool {
371373
/// Initial length of owned objects and anys.
372374
/// `Option` is used since TSL can be broken when `new` is called from `atexit`.
@@ -495,6 +497,7 @@ pub(crate) fn ensure_gil() -> EnsureGIL {
495497
}
496498

497499
/// Struct used internally which avoids acquiring the GIL where it's not necessary.
500+
#[allow(clippy::upper_case_acronyms)]
498501
pub(crate) struct EnsureGIL(Option<GILGuard>);
499502

500503
impl EnsureGIL {

src/lib.rs

Lines changed: 27 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ pub mod derive_utils;
191191
mod err;
192192
pub mod exceptions;
193193
/// Raw ffi declarations for the c interface of python
194-
#[allow(clippy::unknown_clippy_lints)]
194+
#[allow(clippy::upper_case_acronyms)]
195195
#[allow(clippy::missing_safety_doc)]
196196
pub mod ffi;
197197
pub mod freelist;
@@ -398,55 +398,52 @@ macro_rules! py_run_impl {
398398
}
399399

400400
/// Test readme and user guide
401-
#[doc(hidden)]
401+
#[cfg(doctest)]
402402
pub mod doc_test {
403-
macro_rules! doc_comment {
404-
($x:expr, $module:item) => {
405-
#[doc = $x]
406-
$module
403+
macro_rules! doctest_impl {
404+
($doc:expr, $mod:ident) => {
405+
#[doc = $doc]
406+
mod $mod {}
407407
};
408408
}
409409

410410
macro_rules! doctest {
411-
($x:expr, $y:ident) => {
412-
doc_comment!(include_str!($x), mod $y {});
411+
($path:expr, $mod:ident) => {
412+
doctest_impl!(include_str!(concat!("../", $path)), $mod);
413413
};
414414
}
415415

416-
doctest!("../README.md", readme_md);
417-
doctest!("../guide/src/advanced.md", guide_advanced_md);
416+
doctest!("README.md", readme_md);
417+
doctest!("guide/src/advanced.md", guide_advanced_md);
418418
doctest!(
419-
"../guide/src/building_and_distribution.md",
419+
"guide/src/building_and_distribution.md",
420420
guide_building_and_distribution_md
421421
);
422422
doctest!(
423-
"../guide/src/building_and_distribution/pypy.md",
423+
"guide/src/building_and_distribution/pypy.md",
424424
guide_building_and_distribution_pypy_md
425425
);
426-
doctest!("../guide/src/class.md", guide_class_md);
427-
doctest!("../guide/src/class/protocols.md", guide_class_protocols_md);
428-
doctest!("../guide/src/conversions.md", guide_conversions_md);
426+
doctest!("guide/src/class.md", guide_class_md);
427+
doctest!("guide/src/class/protocols.md", guide_class_protocols_md);
428+
doctest!("guide/src/conversions.md", guide_conversions_md);
429429
doctest!(
430-
"../guide/src/conversions/tables.md",
430+
"guide/src/conversions/tables.md",
431431
guide_conversions_tables_md
432432
);
433433
doctest!(
434-
"../guide/src/conversions/traits.md",
434+
"guide/src/conversions/traits.md",
435435
guide_conversions_traits_md
436436
);
437-
doctest!("../guide/src/debugging.md", guide_debugging_md);
438-
doctest!("../guide/src/exception.md", guide_exception_md);
439-
doctest!("../guide/src/function.md", guide_function_md);
440-
doctest!("../guide/src/migration.md", guide_migration_md);
441-
doctest!("../guide/src/module.md", guide_module_md);
442-
doctest!("../guide/src/parallelism.md", guide_parallelism_md);
443-
doctest!(
444-
"../guide/src/python_from_rust.md",
445-
guide_python_from_rust_md
446-
);
447-
doctest!("../guide/src/rust_cpython.md", guide_rust_cpython_md);
448-
doctest!("../guide/src/trait_bounds.md", guide_trait_bounds_md);
449-
doctest!("../guide/src/types.md", guide_types_md);
437+
doctest!("guide/src/debugging.md", guide_debugging_md);
438+
doctest!("guide/src/exception.md", guide_exception_md);
439+
doctest!("guide/src/function.md", guide_function_md);
440+
doctest!("guide/src/migration.md", guide_migration_md);
441+
doctest!("guide/src/module.md", guide_module_md);
442+
doctest!("guide/src/parallelism.md", guide_parallelism_md);
443+
doctest!("guide/src/python_from_rust.md", guide_python_from_rust_md);
444+
doctest!("guide/src/rust_cpython.md", guide_rust_cpython_md);
445+
doctest!("guide/src/trait_bounds.md", guide_trait_bounds_md);
446+
doctest!("guide/src/types.md", guide_types_md);
450447
}
451448

452449
// interim helper until #[cfg(panic = ...)] is stable

src/once_cell.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ use std::cell::UnsafeCell;
2727
/// }
2828
/// # Python::with_gil(|py| assert_eq!(get_shared_list(py).len(), 0));
2929
/// ```
30+
#[allow(clippy::upper_case_acronyms)]
3031
pub struct GILOnceCell<T>(UnsafeCell<Option<T>>);
3132

3233
// T: Send is needed for Sync because the thread which drops the GILOnceCell can be different

tests/test_gc.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,13 @@ fn data_is_dropped() {
8282

8383
#[allow(dead_code)]
8484
#[pyclass]
85-
struct GCIntegration {
85+
struct GcIntegration {
8686
self_ref: PyObject,
8787
dropped: TestDropCall,
8888
}
8989

9090
#[pyproto]
91-
impl PyGCProtocol for GCIntegration {
91+
impl PyGCProtocol for GcIntegration {
9292
fn __traverse__(&self, visit: PyVisit) -> Result<(), PyTraverseError> {
9393
visit.call(&self.self_ref)
9494
}
@@ -108,7 +108,7 @@ fn gc_integration() {
108108
let py = gil.python();
109109
let inst = PyCell::new(
110110
py,
111-
GCIntegration {
111+
GcIntegration {
112112
self_ref: py.None(),
113113
dropped: TestDropCall {
114114
drop_called: Arc::clone(&drop_called),
@@ -128,10 +128,10 @@ fn gc_integration() {
128128
}
129129

130130
#[pyclass(gc)]
131-
struct GCIntegration2 {}
131+
struct GcIntegration2 {}
132132

133133
#[pyproto]
134-
impl PyGCProtocol for GCIntegration2 {
134+
impl PyGCProtocol for GcIntegration2 {
135135
fn __traverse__(&self, _visit: PyVisit) -> Result<(), PyTraverseError> {
136136
Ok(())
137137
}
@@ -142,7 +142,7 @@ impl PyGCProtocol for GCIntegration2 {
142142
fn gc_integration2() {
143143
let gil = Python::acquire_gil();
144144
let py = gil.python();
145-
let inst = PyCell::new(py, GCIntegration2 {}).unwrap();
145+
let inst = PyCell::new(py, GcIntegration2 {}).unwrap();
146146
py_run!(py, inst, "import gc; assert inst in gc.get_objects()");
147147
}
148148

0 commit comments

Comments
 (0)