diff --git a/build.rs b/build.rs index d27cc3b63..7f59e1f57 100644 --- a/build.rs +++ b/build.rs @@ -32,8 +32,8 @@ fn generate_self_schema() { fn main() { pyo3_build_config::use_pyo3_cfgs(); - if let Some(true) = version_check::supports_feature("no_coverage") { - println!("cargo:rustc-cfg=has_no_coverage"); + if let Some(true) = version_check::supports_feature("coverage_attribute") { + println!("cargo:rustc-cfg=has_coverage_attribute"); } generate_self_schema(); println!("cargo:rustc-env=PROFILE={}", std::env::var("PROFILE").unwrap()); diff --git a/src/build_tools.rs b/src/build_tools.rs index 0c8abdf6d..d2bc7c2cd 100644 --- a/src/build_tools.rs +++ b/src/build_tools.rs @@ -67,7 +67,7 @@ impl fmt::Display for SchemaError { } impl Error for SchemaError { - #[cfg_attr(has_no_coverage, no_coverage)] + #[cfg_attr(has_coverage_attribute, coverage(off))] fn source(&self) -> Option<&(dyn Error + 'static)> { None } diff --git a/src/input/input_abstract.rs b/src/input/input_abstract.rs index 3e780237b..d799da473 100644 --- a/src/input/input_abstract.rs +++ b/src/input/input_abstract.rs @@ -80,7 +80,7 @@ pub trait Input<'a>: fmt::Debug + ToPyObject { } } fn strict_str(&'a self) -> ValResult>; - #[cfg_attr(has_no_coverage, no_coverage)] + #[cfg_attr(has_coverage_attribute, coverage(off))] fn lax_str(&'a self) -> ValResult> { self.strict_str() } @@ -93,7 +93,7 @@ pub trait Input<'a>: fmt::Debug + ToPyObject { } } fn strict_bytes(&'a self) -> ValResult>; - #[cfg_attr(has_no_coverage, no_coverage)] + #[cfg_attr(has_coverage_attribute, coverage(off))] fn lax_bytes(&'a self) -> ValResult> { self.strict_bytes() } @@ -106,7 +106,7 @@ pub trait Input<'a>: fmt::Debug + ToPyObject { } } fn strict_bool(&self) -> ValResult; - #[cfg_attr(has_no_coverage, no_coverage)] + #[cfg_attr(has_coverage_attribute, coverage(off))] fn lax_bool(&self) -> ValResult { self.strict_bool() } @@ -119,7 +119,7 @@ pub trait Input<'a>: fmt::Debug + ToPyObject { } } fn strict_int(&'a self) -> ValResult>; - #[cfg_attr(has_no_coverage, no_coverage)] + #[cfg_attr(has_coverage_attribute, coverage(off))] fn lax_int(&'a self) -> ValResult> { self.strict_int() } @@ -147,7 +147,7 @@ pub trait Input<'a>: fmt::Debug + ToPyObject { } fn ultra_strict_float(&'a self) -> ValResult>; fn strict_float(&'a self) -> ValResult>; - #[cfg_attr(has_no_coverage, no_coverage)] + #[cfg_attr(has_coverage_attribute, coverage(off))] fn lax_float(&'a self) -> ValResult> { self.strict_float() } @@ -160,7 +160,7 @@ pub trait Input<'a>: fmt::Debug + ToPyObject { } } fn strict_decimal(&'a self, py: Python<'a>) -> ValResult<&'a PyAny>; - #[cfg_attr(has_no_coverage, no_coverage)] + #[cfg_attr(has_coverage_attribute, coverage(off))] fn lax_decimal(&'a self, py: Python<'a>) -> ValResult<&'a PyAny> { self.strict_decimal(py) } @@ -173,7 +173,7 @@ pub trait Input<'a>: fmt::Debug + ToPyObject { } } fn strict_dict(&'a self) -> ValResult>; - #[cfg_attr(has_no_coverage, no_coverage)] + #[cfg_attr(has_coverage_attribute, coverage(off))] fn lax_dict(&'a self) -> ValResult> { self.strict_dict() } @@ -190,7 +190,7 @@ pub trait Input<'a>: fmt::Debug + ToPyObject { } } fn strict_list(&'a self) -> ValResult>; - #[cfg_attr(has_no_coverage, no_coverage)] + #[cfg_attr(has_coverage_attribute, coverage(off))] fn lax_list(&'a self) -> ValResult> { self.strict_list() } @@ -203,7 +203,7 @@ pub trait Input<'a>: fmt::Debug + ToPyObject { } } fn strict_tuple(&'a self) -> ValResult>; - #[cfg_attr(has_no_coverage, no_coverage)] + #[cfg_attr(has_coverage_attribute, coverage(off))] fn lax_tuple(&'a self) -> ValResult> { self.strict_tuple() } @@ -216,7 +216,7 @@ pub trait Input<'a>: fmt::Debug + ToPyObject { } } fn strict_set(&'a self) -> ValResult>; - #[cfg_attr(has_no_coverage, no_coverage)] + #[cfg_attr(has_coverage_attribute, coverage(off))] fn lax_set(&'a self) -> ValResult> { self.strict_set() } @@ -229,7 +229,7 @@ pub trait Input<'a>: fmt::Debug + ToPyObject { } } fn strict_frozenset(&'a self) -> ValResult>; - #[cfg_attr(has_no_coverage, no_coverage)] + #[cfg_attr(has_coverage_attribute, coverage(off))] fn lax_frozenset(&'a self) -> ValResult> { self.strict_frozenset() } @@ -246,7 +246,7 @@ pub trait Input<'a>: fmt::Debug + ToPyObject { } } fn strict_date(&self) -> ValResult; - #[cfg_attr(has_no_coverage, no_coverage)] + #[cfg_attr(has_coverage_attribute, coverage(off))] fn lax_date(&self) -> ValResult { self.strict_date() } @@ -266,7 +266,7 @@ pub trait Input<'a>: fmt::Debug + ToPyObject { &self, microseconds_overflow_behavior: speedate::MicrosecondsPrecisionOverflowBehavior, ) -> ValResult; - #[cfg_attr(has_no_coverage, no_coverage)] + #[cfg_attr(has_coverage_attribute, coverage(off))] fn lax_time( &self, microseconds_overflow_behavior: speedate::MicrosecondsPrecisionOverflowBehavior, @@ -289,7 +289,7 @@ pub trait Input<'a>: fmt::Debug + ToPyObject { &self, microseconds_overflow_behavior: speedate::MicrosecondsPrecisionOverflowBehavior, ) -> ValResult; - #[cfg_attr(has_no_coverage, no_coverage)] + #[cfg_attr(has_coverage_attribute, coverage(off))] fn lax_datetime( &self, microseconds_overflow_behavior: speedate::MicrosecondsPrecisionOverflowBehavior, @@ -312,7 +312,7 @@ pub trait Input<'a>: fmt::Debug + ToPyObject { &self, microseconds_overflow_behavior: speedate::MicrosecondsPrecisionOverflowBehavior, ) -> ValResult; - #[cfg_attr(has_no_coverage, no_coverage)] + #[cfg_attr(has_coverage_attribute, coverage(off))] fn lax_timedelta( &self, microseconds_overflow_behavior: speedate::MicrosecondsPrecisionOverflowBehavior, diff --git a/src/input/input_json.rs b/src/input/input_json.rs index d9cb81fe2..d948e2493 100644 --- a/src/input/input_json.rs +++ b/src/input/input_json.rs @@ -21,7 +21,7 @@ use super::{ impl<'a> Input<'a> for JsonInput { /// This is required by since JSON object keys are always strings, I don't think it can be called - #[cfg_attr(has_no_coverage, no_coverage)] + #[cfg_attr(has_coverage_attribute, coverage(off))] fn as_loc_item(&self) -> LocItem { match self { JsonInput::Int(i) => (*i).into(), @@ -102,7 +102,7 @@ impl<'a> Input<'a> for JsonInput { _ => Err(ValError::new(ErrorTypeDefaults::BytesType, self)), } } - #[cfg_attr(has_no_coverage, no_coverage)] + #[cfg_attr(has_coverage_attribute, coverage(off))] fn strict_bytes(&'a self) -> ValResult> { self.validate_bytes(false) } @@ -196,7 +196,7 @@ impl<'a> Input<'a> for JsonInput { _ => Err(ValError::new(ErrorTypeDefaults::DictType, self)), } } - #[cfg_attr(has_no_coverage, no_coverage)] + #[cfg_attr(has_coverage_attribute, coverage(off))] fn strict_dict(&'a self) -> ValResult> { self.validate_dict(false) } @@ -207,7 +207,7 @@ impl<'a> Input<'a> for JsonInput { _ => Err(ValError::new(ErrorTypeDefaults::ListType, self)), } } - #[cfg_attr(has_no_coverage, no_coverage)] + #[cfg_attr(has_coverage_attribute, coverage(off))] fn strict_list(&'a self) -> ValResult> { self.validate_list(false) } @@ -219,7 +219,7 @@ impl<'a> Input<'a> for JsonInput { _ => Err(ValError::new(ErrorTypeDefaults::TupleType, self)), } } - #[cfg_attr(has_no_coverage, no_coverage)] + #[cfg_attr(has_coverage_attribute, coverage(off))] fn strict_tuple(&'a self) -> ValResult> { self.validate_tuple(false) } @@ -231,7 +231,7 @@ impl<'a> Input<'a> for JsonInput { _ => Err(ValError::new(ErrorTypeDefaults::SetType, self)), } } - #[cfg_attr(has_no_coverage, no_coverage)] + #[cfg_attr(has_coverage_attribute, coverage(off))] fn strict_set(&'a self) -> ValResult> { self.validate_set(false) } @@ -243,7 +243,7 @@ impl<'a> Input<'a> for JsonInput { _ => Err(ValError::new(ErrorTypeDefaults::FrozenSetType, self)), } } - #[cfg_attr(has_no_coverage, no_coverage)] + #[cfg_attr(has_coverage_attribute, coverage(off))] fn strict_frozenset(&'a self) -> ValResult> { self.validate_frozenset(false) } @@ -278,7 +278,7 @@ impl<'a> Input<'a> for JsonInput { } // NO custom `lax_date` implementation, if strict_date fails, the validator will fallback to lax_datetime // then check there's no remainder - #[cfg_attr(has_no_coverage, no_coverage)] + #[cfg_attr(has_coverage_attribute, coverage(off))] fn strict_date(&self) -> ValResult { self.validate_date(false) } @@ -365,7 +365,7 @@ impl<'a> Input<'a> for String { InputValue::String(self) } - #[cfg_attr(has_no_coverage, no_coverage)] + #[cfg_attr(has_coverage_attribute, coverage(off))] fn is_none(&self) -> bool { false } @@ -374,12 +374,12 @@ impl<'a> Input<'a> for String { None } - #[cfg_attr(has_no_coverage, no_coverage)] + #[cfg_attr(has_coverage_attribute, coverage(off))] fn validate_args(&'a self) -> ValResult<'a, GenericArguments<'a>> { Err(ValError::new(ErrorTypeDefaults::ArgumentsType, self)) } - #[cfg_attr(has_no_coverage, no_coverage)] + #[cfg_attr(has_coverage_attribute, coverage(off))] fn validate_dataclass_args(&'a self, class_name: &str) -> ValResult<'a, GenericArguments<'a>> { let class_name = class_name.to_string(); Err(ValError::new( @@ -405,7 +405,7 @@ impl<'a> Input<'a> for String { fn validate_bytes(&'a self, _strict: bool) -> ValResult> { Ok(self.as_bytes().into()) } - #[cfg_attr(has_no_coverage, no_coverage)] + #[cfg_attr(has_coverage_attribute, coverage(off))] fn strict_bytes(&'a self) -> ValResult> { self.validate_bytes(false) } @@ -427,11 +427,11 @@ impl<'a> Input<'a> for String { } } - #[cfg_attr(has_no_coverage, no_coverage)] + #[cfg_attr(has_coverage_attribute, coverage(off))] fn ultra_strict_float(&'a self) -> ValResult> { self.strict_float() } - #[cfg_attr(has_no_coverage, no_coverage)] + #[cfg_attr(has_coverage_attribute, coverage(off))] fn strict_float(&'a self) -> ValResult> { Err(ValError::new(ErrorTypeDefaults::FloatType, self)) } @@ -443,47 +443,47 @@ impl<'a> Input<'a> for String { create_decimal(self.to_object(py).into_ref(py), self, py) } - #[cfg_attr(has_no_coverage, no_coverage)] + #[cfg_attr(has_coverage_attribute, coverage(off))] fn validate_dict(&'a self, _strict: bool) -> ValResult> { Err(ValError::new(ErrorTypeDefaults::DictType, self)) } - #[cfg_attr(has_no_coverage, no_coverage)] + #[cfg_attr(has_coverage_attribute, coverage(off))] fn strict_dict(&'a self) -> ValResult> { self.validate_dict(false) } - #[cfg_attr(has_no_coverage, no_coverage)] + #[cfg_attr(has_coverage_attribute, coverage(off))] fn validate_list(&'a self, _strict: bool) -> ValResult> { Err(ValError::new(ErrorTypeDefaults::ListType, self)) } - #[cfg_attr(has_no_coverage, no_coverage)] + #[cfg_attr(has_coverage_attribute, coverage(off))] fn strict_list(&'a self) -> ValResult> { self.validate_list(false) } - #[cfg_attr(has_no_coverage, no_coverage)] + #[cfg_attr(has_coverage_attribute, coverage(off))] fn validate_tuple(&'a self, _strict: bool) -> ValResult> { Err(ValError::new(ErrorTypeDefaults::TupleType, self)) } - #[cfg_attr(has_no_coverage, no_coverage)] + #[cfg_attr(has_coverage_attribute, coverage(off))] fn strict_tuple(&'a self) -> ValResult> { self.validate_tuple(false) } - #[cfg_attr(has_no_coverage, no_coverage)] + #[cfg_attr(has_coverage_attribute, coverage(off))] fn validate_set(&'a self, _strict: bool) -> ValResult> { Err(ValError::new(ErrorTypeDefaults::SetType, self)) } - #[cfg_attr(has_no_coverage, no_coverage)] + #[cfg_attr(has_coverage_attribute, coverage(off))] fn strict_set(&'a self) -> ValResult> { self.validate_set(false) } - #[cfg_attr(has_no_coverage, no_coverage)] + #[cfg_attr(has_coverage_attribute, coverage(off))] fn validate_frozenset(&'a self, _strict: bool) -> ValResult> { Err(ValError::new(ErrorTypeDefaults::FrozenSetType, self)) } - #[cfg_attr(has_no_coverage, no_coverage)] + #[cfg_attr(has_coverage_attribute, coverage(off))] fn strict_frozenset(&'a self) -> ValResult> { self.validate_frozenset(false) } @@ -499,7 +499,7 @@ impl<'a> Input<'a> for String { fn validate_date(&self, _strict: bool) -> ValResult { bytes_as_date(self, self.as_bytes()) } - #[cfg_attr(has_no_coverage, no_coverage)] + #[cfg_attr(has_coverage_attribute, coverage(off))] fn strict_date(&self) -> ValResult { self.validate_date(false) } @@ -511,7 +511,7 @@ impl<'a> Input<'a> for String { ) -> ValResult { bytes_as_time(self, self.as_bytes(), microseconds_overflow_behavior) } - #[cfg_attr(has_no_coverage, no_coverage)] + #[cfg_attr(has_coverage_attribute, coverage(off))] fn strict_time( &self, microseconds_overflow_behavior: speedate::MicrosecondsPrecisionOverflowBehavior, @@ -526,7 +526,7 @@ impl<'a> Input<'a> for String { ) -> ValResult { bytes_as_datetime(self, self.as_bytes(), microseconds_overflow_behavior) } - #[cfg_attr(has_no_coverage, no_coverage)] + #[cfg_attr(has_coverage_attribute, coverage(off))] fn strict_datetime( &self, microseconds_overflow_behavior: speedate::MicrosecondsPrecisionOverflowBehavior, @@ -541,7 +541,7 @@ impl<'a> Input<'a> for String { ) -> ValResult { bytes_as_timedelta(self, self.as_bytes(), microseconds_overflow_behavior) } - #[cfg_attr(has_no_coverage, no_coverage)] + #[cfg_attr(has_coverage_attribute, coverage(off))] fn strict_timedelta( &self, microseconds_overflow_behavior: speedate::MicrosecondsPrecisionOverflowBehavior, diff --git a/src/input/parse_json.rs b/src/input/parse_json.rs index 7603eaf67..20a107669 100644 --- a/src/input/parse_json.rs +++ b/src/input/parse_json.rs @@ -57,7 +57,7 @@ impl<'de> Deserialize<'de> for JsonInput { impl<'de> Visitor<'de> for JsonVisitor { type Value = JsonInput; - #[cfg_attr(has_no_coverage, no_coverage)] + #[cfg_attr(has_coverage_attribute, coverage(off))] fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { formatter.write_str("any valid JSON value") } @@ -92,12 +92,12 @@ impl<'de> Deserialize<'de> for JsonInput { Ok(JsonInput::String(value)) } - #[cfg_attr(has_no_coverage, no_coverage)] + #[cfg_attr(has_coverage_attribute, coverage(off))] fn visit_none(self) -> Result { unreachable!() } - #[cfg_attr(has_no_coverage, no_coverage)] + #[cfg_attr(has_coverage_attribute, coverage(off))] fn visit_some(self, _: D) -> Result where D: serde::Deserializer<'de>, @@ -200,7 +200,7 @@ impl<'de> DeserializeSeed<'de> for KeyDeserializer { impl<'de> Visitor<'de> for KeyDeserializer { type Value = String; - #[cfg_attr(has_no_coverage, no_coverage)] + #[cfg_attr(has_coverage_attribute, coverage(off))] fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { formatter.write_str("a string key") } @@ -212,7 +212,7 @@ impl<'de> Visitor<'de> for KeyDeserializer { Ok(s.to_string()) } - #[cfg_attr(has_no_coverage, no_coverage)] + #[cfg_attr(has_coverage_attribute, coverage(off))] fn visit_string(self, _: String) -> Result where E: serde::de::Error, diff --git a/src/lib.rs b/src/lib.rs index 56efbc87f..cbf668b9d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,4 @@ -#![cfg_attr(has_no_coverage, feature(no_coverage))] +#![cfg_attr(has_coverage_attribute, feature(coverage_attribute))] extern crate core; diff --git a/src/tools.rs b/src/tools.rs index 71f7ad60e..3c75decf1 100644 --- a/src/tools.rs +++ b/src/tools.rs @@ -48,7 +48,7 @@ impl<'py> SchemaDict<'py> for Option<&PyDict> { } } - #[cfg_attr(has_no_coverage, no_coverage)] + #[cfg_attr(has_coverage_attribute, coverage(off))] fn get_as_req(&'py self, key: &PyString) -> PyResult where T: FromPyObject<'py>,