Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 1 addition & 14 deletions src/rust/src/declarative_asn1/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ impl Null {
}

#[derive(pyo3::FromPyObject)]
#[pyo3::pyclass(frozen, module = "cryptography.hazmat.bindings._rust.asn1")]
#[pyo3::pyclass(frozen, generic, module = "cryptography.hazmat.bindings._rust.asn1")]
pub struct SetOf {
pub(crate) inner: pyo3::Py<pyo3::types::PyList>,
}
Expand All @@ -497,19 +497,6 @@ impl SetOf {
fn __repr__(&self, py: pyo3::Python<'_>) -> pyo3::PyResult<String> {
Ok(format!("SetOf({})", self.inner.bind(py).repr()?))
}

// TODO: replace this manual `__class_getitem__` with
// `#[pyclass(generic)]`, which uses `pyo3::types::PyGenericAlias` to
// create `types.GenericAlias` objects.
#[classmethod]
fn __class_getitem__(
cls: &pyo3::Bound<'_, pyo3::types::PyType>,
py: pyo3::Python<'_>,
item: &pyo3::Bound<'_, pyo3::PyAny>,
) -> pyo3::PyResult<pyo3::Py<pyo3::PyAny>> {
let generic_alias = crate::types::TYPES_GENERICALIAS.get(py)?;
Ok(generic_alias.call1((cls, item))?.unbind())
}
}

/// Utility function for converting builtin Python types
Expand Down
1 change: 0 additions & 1 deletion src/rust/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ pub static DATETIME_TIMEZONE_UTC: LazyPyImport =
LazyPyImport::new("datetime", &["timezone", "utc"]);
pub static IPADDRESS_IPADDRESS: LazyPyImport = LazyPyImport::new("ipaddress", &["ip_address"]);
pub static IPADDRESS_IPNETWORK: LazyPyImport = LazyPyImport::new("ipaddress", &["ip_network"]);
pub static TYPES_GENERICALIAS: LazyPyImport = LazyPyImport::new("types", &["GenericAlias"]);

pub static DEPRECATED_IN_36: LazyPyImport =
LazyPyImport::new("cryptography.utils", &["DeprecatedIn36"]);
Expand Down