Skip to content

Commit 67c3cff

Browse files
committed
update to coverage_attribute feature
1 parent 5edddd5 commit 67c3cff

File tree

7 files changed

+53
-53
lines changed

7 files changed

+53
-53
lines changed

build.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ fn generate_self_schema() {
3232

3333
fn main() {
3434
pyo3_build_config::use_pyo3_cfgs();
35-
if let Some(true) = version_check::supports_feature("no_coverage") {
36-
println!("cargo:rustc-cfg=has_no_coverage");
35+
if let Some(true) = version_check::supports_feature("coverage_attribute") {
36+
println!("cargo:rustc-cfg=has_coverage_attribute");
3737
}
3838
generate_self_schema();
3939
println!("cargo:rustc-env=PROFILE={}", std::env::var("PROFILE").unwrap());

src/build_tools.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ impl fmt::Display for SchemaError {
6767
}
6868

6969
impl Error for SchemaError {
70-
#[cfg_attr(has_no_coverage, no_coverage)]
70+
#[cfg_attr(has_coverage_attribute, coverage(off))]
7171
fn source(&self) -> Option<&(dyn Error + 'static)> {
7272
None
7373
}

src/input/input_abstract.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ pub trait Input<'a>: fmt::Debug + ToPyObject {
8080
}
8181
}
8282
fn strict_str(&'a self) -> ValResult<EitherString<'a>>;
83-
#[cfg_attr(has_no_coverage, no_coverage)]
83+
#[cfg_attr(has_coverage_attribute, coverage(off))]
8484
fn lax_str(&'a self) -> ValResult<EitherString<'a>> {
8585
self.strict_str()
8686
}
@@ -93,7 +93,7 @@ pub trait Input<'a>: fmt::Debug + ToPyObject {
9393
}
9494
}
9595
fn strict_bytes(&'a self) -> ValResult<EitherBytes<'a>>;
96-
#[cfg_attr(has_no_coverage, no_coverage)]
96+
#[cfg_attr(has_coverage_attribute, coverage(off))]
9797
fn lax_bytes(&'a self) -> ValResult<EitherBytes<'a>> {
9898
self.strict_bytes()
9999
}
@@ -106,7 +106,7 @@ pub trait Input<'a>: fmt::Debug + ToPyObject {
106106
}
107107
}
108108
fn strict_bool(&self) -> ValResult<bool>;
109-
#[cfg_attr(has_no_coverage, no_coverage)]
109+
#[cfg_attr(has_coverage_attribute, coverage(off))]
110110
fn lax_bool(&self) -> ValResult<bool> {
111111
self.strict_bool()
112112
}
@@ -119,7 +119,7 @@ pub trait Input<'a>: fmt::Debug + ToPyObject {
119119
}
120120
}
121121
fn strict_int(&'a self) -> ValResult<EitherInt<'a>>;
122-
#[cfg_attr(has_no_coverage, no_coverage)]
122+
#[cfg_attr(has_coverage_attribute, coverage(off))]
123123
fn lax_int(&'a self) -> ValResult<EitherInt<'a>> {
124124
self.strict_int()
125125
}
@@ -147,7 +147,7 @@ pub trait Input<'a>: fmt::Debug + ToPyObject {
147147
}
148148
fn ultra_strict_float(&'a self) -> ValResult<EitherFloat<'a>>;
149149
fn strict_float(&'a self) -> ValResult<EitherFloat<'a>>;
150-
#[cfg_attr(has_no_coverage, no_coverage)]
150+
#[cfg_attr(has_coverage_attribute, coverage(off))]
151151
fn lax_float(&'a self) -> ValResult<EitherFloat<'a>> {
152152
self.strict_float()
153153
}
@@ -160,7 +160,7 @@ pub trait Input<'a>: fmt::Debug + ToPyObject {
160160
}
161161
}
162162
fn strict_decimal(&'a self, py: Python<'a>) -> ValResult<&'a PyAny>;
163-
#[cfg_attr(has_no_coverage, no_coverage)]
163+
#[cfg_attr(has_coverage_attribute, coverage(off))]
164164
fn lax_decimal(&'a self, py: Python<'a>) -> ValResult<&'a PyAny> {
165165
self.strict_decimal(py)
166166
}
@@ -173,7 +173,7 @@ pub trait Input<'a>: fmt::Debug + ToPyObject {
173173
}
174174
}
175175
fn strict_dict(&'a self) -> ValResult<GenericMapping<'a>>;
176-
#[cfg_attr(has_no_coverage, no_coverage)]
176+
#[cfg_attr(has_coverage_attribute, coverage(off))]
177177
fn lax_dict(&'a self) -> ValResult<GenericMapping<'a>> {
178178
self.strict_dict()
179179
}
@@ -190,7 +190,7 @@ pub trait Input<'a>: fmt::Debug + ToPyObject {
190190
}
191191
}
192192
fn strict_list(&'a self) -> ValResult<GenericIterable<'a>>;
193-
#[cfg_attr(has_no_coverage, no_coverage)]
193+
#[cfg_attr(has_coverage_attribute, coverage(off))]
194194
fn lax_list(&'a self) -> ValResult<GenericIterable<'a>> {
195195
self.strict_list()
196196
}
@@ -203,7 +203,7 @@ pub trait Input<'a>: fmt::Debug + ToPyObject {
203203
}
204204
}
205205
fn strict_tuple(&'a self) -> ValResult<GenericIterable<'a>>;
206-
#[cfg_attr(has_no_coverage, no_coverage)]
206+
#[cfg_attr(has_coverage_attribute, coverage(off))]
207207
fn lax_tuple(&'a self) -> ValResult<GenericIterable<'a>> {
208208
self.strict_tuple()
209209
}
@@ -216,7 +216,7 @@ pub trait Input<'a>: fmt::Debug + ToPyObject {
216216
}
217217
}
218218
fn strict_set(&'a self) -> ValResult<GenericIterable<'a>>;
219-
#[cfg_attr(has_no_coverage, no_coverage)]
219+
#[cfg_attr(has_coverage_attribute, coverage(off))]
220220
fn lax_set(&'a self) -> ValResult<GenericIterable<'a>> {
221221
self.strict_set()
222222
}
@@ -229,7 +229,7 @@ pub trait Input<'a>: fmt::Debug + ToPyObject {
229229
}
230230
}
231231
fn strict_frozenset(&'a self) -> ValResult<GenericIterable<'a>>;
232-
#[cfg_attr(has_no_coverage, no_coverage)]
232+
#[cfg_attr(has_coverage_attribute, coverage(off))]
233233
fn lax_frozenset(&'a self) -> ValResult<GenericIterable<'a>> {
234234
self.strict_frozenset()
235235
}
@@ -246,7 +246,7 @@ pub trait Input<'a>: fmt::Debug + ToPyObject {
246246
}
247247
}
248248
fn strict_date(&self) -> ValResult<EitherDate>;
249-
#[cfg_attr(has_no_coverage, no_coverage)]
249+
#[cfg_attr(has_coverage_attribute, coverage(off))]
250250
fn lax_date(&self) -> ValResult<EitherDate> {
251251
self.strict_date()
252252
}
@@ -266,7 +266,7 @@ pub trait Input<'a>: fmt::Debug + ToPyObject {
266266
&self,
267267
microseconds_overflow_behavior: speedate::MicrosecondsPrecisionOverflowBehavior,
268268
) -> ValResult<EitherTime>;
269-
#[cfg_attr(has_no_coverage, no_coverage)]
269+
#[cfg_attr(has_coverage_attribute, coverage(off))]
270270
fn lax_time(
271271
&self,
272272
microseconds_overflow_behavior: speedate::MicrosecondsPrecisionOverflowBehavior,
@@ -289,7 +289,7 @@ pub trait Input<'a>: fmt::Debug + ToPyObject {
289289
&self,
290290
microseconds_overflow_behavior: speedate::MicrosecondsPrecisionOverflowBehavior,
291291
) -> ValResult<EitherDateTime>;
292-
#[cfg_attr(has_no_coverage, no_coverage)]
292+
#[cfg_attr(has_coverage_attribute, coverage(off))]
293293
fn lax_datetime(
294294
&self,
295295
microseconds_overflow_behavior: speedate::MicrosecondsPrecisionOverflowBehavior,
@@ -312,7 +312,7 @@ pub trait Input<'a>: fmt::Debug + ToPyObject {
312312
&self,
313313
microseconds_overflow_behavior: speedate::MicrosecondsPrecisionOverflowBehavior,
314314
) -> ValResult<EitherTimedelta>;
315-
#[cfg_attr(has_no_coverage, no_coverage)]
315+
#[cfg_attr(has_coverage_attribute, coverage(off))]
316316
fn lax_timedelta(
317317
&self,
318318
microseconds_overflow_behavior: speedate::MicrosecondsPrecisionOverflowBehavior,

src/input/input_json.rs

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use super::{
2121

2222
impl<'a> Input<'a> for JsonInput {
2323
/// This is required by since JSON object keys are always strings, I don't think it can be called
24-
#[cfg_attr(has_no_coverage, no_coverage)]
24+
#[cfg_attr(has_coverage_attribute, coverage(off))]
2525
fn as_loc_item(&self) -> LocItem {
2626
match self {
2727
JsonInput::Int(i) => (*i).into(),
@@ -102,7 +102,7 @@ impl<'a> Input<'a> for JsonInput {
102102
_ => Err(ValError::new(ErrorTypeDefaults::BytesType, self)),
103103
}
104104
}
105-
#[cfg_attr(has_no_coverage, no_coverage)]
105+
#[cfg_attr(has_coverage_attribute, coverage(off))]
106106
fn strict_bytes(&'a self) -> ValResult<EitherBytes<'a>> {
107107
self.validate_bytes(false)
108108
}
@@ -196,7 +196,7 @@ impl<'a> Input<'a> for JsonInput {
196196
_ => Err(ValError::new(ErrorTypeDefaults::DictType, self)),
197197
}
198198
}
199-
#[cfg_attr(has_no_coverage, no_coverage)]
199+
#[cfg_attr(has_coverage_attribute, coverage(off))]
200200
fn strict_dict(&'a self) -> ValResult<GenericMapping<'a>> {
201201
self.validate_dict(false)
202202
}
@@ -207,7 +207,7 @@ impl<'a> Input<'a> for JsonInput {
207207
_ => Err(ValError::new(ErrorTypeDefaults::ListType, self)),
208208
}
209209
}
210-
#[cfg_attr(has_no_coverage, no_coverage)]
210+
#[cfg_attr(has_coverage_attribute, coverage(off))]
211211
fn strict_list(&'a self) -> ValResult<GenericIterable<'a>> {
212212
self.validate_list(false)
213213
}
@@ -219,7 +219,7 @@ impl<'a> Input<'a> for JsonInput {
219219
_ => Err(ValError::new(ErrorTypeDefaults::TupleType, self)),
220220
}
221221
}
222-
#[cfg_attr(has_no_coverage, no_coverage)]
222+
#[cfg_attr(has_coverage_attribute, coverage(off))]
223223
fn strict_tuple(&'a self) -> ValResult<GenericIterable<'a>> {
224224
self.validate_tuple(false)
225225
}
@@ -231,7 +231,7 @@ impl<'a> Input<'a> for JsonInput {
231231
_ => Err(ValError::new(ErrorTypeDefaults::SetType, self)),
232232
}
233233
}
234-
#[cfg_attr(has_no_coverage, no_coverage)]
234+
#[cfg_attr(has_coverage_attribute, coverage(off))]
235235
fn strict_set(&'a self) -> ValResult<GenericIterable<'a>> {
236236
self.validate_set(false)
237237
}
@@ -243,7 +243,7 @@ impl<'a> Input<'a> for JsonInput {
243243
_ => Err(ValError::new(ErrorTypeDefaults::FrozenSetType, self)),
244244
}
245245
}
246-
#[cfg_attr(has_no_coverage, no_coverage)]
246+
#[cfg_attr(has_coverage_attribute, coverage(off))]
247247
fn strict_frozenset(&'a self) -> ValResult<GenericIterable<'a>> {
248248
self.validate_frozenset(false)
249249
}
@@ -278,7 +278,7 @@ impl<'a> Input<'a> for JsonInput {
278278
}
279279
// NO custom `lax_date` implementation, if strict_date fails, the validator will fallback to lax_datetime
280280
// then check there's no remainder
281-
#[cfg_attr(has_no_coverage, no_coverage)]
281+
#[cfg_attr(has_coverage_attribute, coverage(off))]
282282
fn strict_date(&self) -> ValResult<EitherDate> {
283283
self.validate_date(false)
284284
}
@@ -365,7 +365,7 @@ impl<'a> Input<'a> for String {
365365
InputValue::String(self)
366366
}
367367

368-
#[cfg_attr(has_no_coverage, no_coverage)]
368+
#[cfg_attr(has_coverage_attribute, coverage(off))]
369369
fn is_none(&self) -> bool {
370370
false
371371
}
@@ -374,12 +374,12 @@ impl<'a> Input<'a> for String {
374374
None
375375
}
376376

377-
#[cfg_attr(has_no_coverage, no_coverage)]
377+
#[cfg_attr(has_coverage_attribute, coverage(off))]
378378
fn validate_args(&'a self) -> ValResult<'a, GenericArguments<'a>> {
379379
Err(ValError::new(ErrorTypeDefaults::ArgumentsType, self))
380380
}
381381

382-
#[cfg_attr(has_no_coverage, no_coverage)]
382+
#[cfg_attr(has_coverage_attribute, coverage(off))]
383383
fn validate_dataclass_args(&'a self, class_name: &str) -> ValResult<'a, GenericArguments<'a>> {
384384
let class_name = class_name.to_string();
385385
Err(ValError::new(
@@ -405,7 +405,7 @@ impl<'a> Input<'a> for String {
405405
fn validate_bytes(&'a self, _strict: bool) -> ValResult<EitherBytes<'a>> {
406406
Ok(self.as_bytes().into())
407407
}
408-
#[cfg_attr(has_no_coverage, no_coverage)]
408+
#[cfg_attr(has_coverage_attribute, coverage(off))]
409409
fn strict_bytes(&'a self) -> ValResult<EitherBytes<'a>> {
410410
self.validate_bytes(false)
411411
}
@@ -427,11 +427,11 @@ impl<'a> Input<'a> for String {
427427
}
428428
}
429429

430-
#[cfg_attr(has_no_coverage, no_coverage)]
430+
#[cfg_attr(has_coverage_attribute, coverage(off))]
431431
fn ultra_strict_float(&'a self) -> ValResult<EitherFloat<'a>> {
432432
self.strict_float()
433433
}
434-
#[cfg_attr(has_no_coverage, no_coverage)]
434+
#[cfg_attr(has_coverage_attribute, coverage(off))]
435435
fn strict_float(&'a self) -> ValResult<EitherFloat<'a>> {
436436
Err(ValError::new(ErrorTypeDefaults::FloatType, self))
437437
}
@@ -443,47 +443,47 @@ impl<'a> Input<'a> for String {
443443
create_decimal(self.to_object(py).into_ref(py), self, py)
444444
}
445445

446-
#[cfg_attr(has_no_coverage, no_coverage)]
446+
#[cfg_attr(has_coverage_attribute, coverage(off))]
447447
fn validate_dict(&'a self, _strict: bool) -> ValResult<GenericMapping<'a>> {
448448
Err(ValError::new(ErrorTypeDefaults::DictType, self))
449449
}
450-
#[cfg_attr(has_no_coverage, no_coverage)]
450+
#[cfg_attr(has_coverage_attribute, coverage(off))]
451451
fn strict_dict(&'a self) -> ValResult<GenericMapping<'a>> {
452452
self.validate_dict(false)
453453
}
454454

455-
#[cfg_attr(has_no_coverage, no_coverage)]
455+
#[cfg_attr(has_coverage_attribute, coverage(off))]
456456
fn validate_list(&'a self, _strict: bool) -> ValResult<GenericIterable<'a>> {
457457
Err(ValError::new(ErrorTypeDefaults::ListType, self))
458458
}
459-
#[cfg_attr(has_no_coverage, no_coverage)]
459+
#[cfg_attr(has_coverage_attribute, coverage(off))]
460460
fn strict_list(&'a self) -> ValResult<GenericIterable<'a>> {
461461
self.validate_list(false)
462462
}
463463

464-
#[cfg_attr(has_no_coverage, no_coverage)]
464+
#[cfg_attr(has_coverage_attribute, coverage(off))]
465465
fn validate_tuple(&'a self, _strict: bool) -> ValResult<GenericIterable<'a>> {
466466
Err(ValError::new(ErrorTypeDefaults::TupleType, self))
467467
}
468-
#[cfg_attr(has_no_coverage, no_coverage)]
468+
#[cfg_attr(has_coverage_attribute, coverage(off))]
469469
fn strict_tuple(&'a self) -> ValResult<GenericIterable<'a>> {
470470
self.validate_tuple(false)
471471
}
472472

473-
#[cfg_attr(has_no_coverage, no_coverage)]
473+
#[cfg_attr(has_coverage_attribute, coverage(off))]
474474
fn validate_set(&'a self, _strict: bool) -> ValResult<GenericIterable<'a>> {
475475
Err(ValError::new(ErrorTypeDefaults::SetType, self))
476476
}
477-
#[cfg_attr(has_no_coverage, no_coverage)]
477+
#[cfg_attr(has_coverage_attribute, coverage(off))]
478478
fn strict_set(&'a self) -> ValResult<GenericIterable<'a>> {
479479
self.validate_set(false)
480480
}
481481

482-
#[cfg_attr(has_no_coverage, no_coverage)]
482+
#[cfg_attr(has_coverage_attribute, coverage(off))]
483483
fn validate_frozenset(&'a self, _strict: bool) -> ValResult<GenericIterable<'a>> {
484484
Err(ValError::new(ErrorTypeDefaults::FrozenSetType, self))
485485
}
486-
#[cfg_attr(has_no_coverage, no_coverage)]
486+
#[cfg_attr(has_coverage_attribute, coverage(off))]
487487
fn strict_frozenset(&'a self) -> ValResult<GenericIterable<'a>> {
488488
self.validate_frozenset(false)
489489
}
@@ -499,7 +499,7 @@ impl<'a> Input<'a> for String {
499499
fn validate_date(&self, _strict: bool) -> ValResult<EitherDate> {
500500
bytes_as_date(self, self.as_bytes())
501501
}
502-
#[cfg_attr(has_no_coverage, no_coverage)]
502+
#[cfg_attr(has_coverage_attribute, coverage(off))]
503503
fn strict_date(&self) -> ValResult<EitherDate> {
504504
self.validate_date(false)
505505
}
@@ -511,7 +511,7 @@ impl<'a> Input<'a> for String {
511511
) -> ValResult<EitherTime> {
512512
bytes_as_time(self, self.as_bytes(), microseconds_overflow_behavior)
513513
}
514-
#[cfg_attr(has_no_coverage, no_coverage)]
514+
#[cfg_attr(has_coverage_attribute, coverage(off))]
515515
fn strict_time(
516516
&self,
517517
microseconds_overflow_behavior: speedate::MicrosecondsPrecisionOverflowBehavior,
@@ -526,7 +526,7 @@ impl<'a> Input<'a> for String {
526526
) -> ValResult<EitherDateTime> {
527527
bytes_as_datetime(self, self.as_bytes(), microseconds_overflow_behavior)
528528
}
529-
#[cfg_attr(has_no_coverage, no_coverage)]
529+
#[cfg_attr(has_coverage_attribute, coverage(off))]
530530
fn strict_datetime(
531531
&self,
532532
microseconds_overflow_behavior: speedate::MicrosecondsPrecisionOverflowBehavior,
@@ -541,7 +541,7 @@ impl<'a> Input<'a> for String {
541541
) -> ValResult<EitherTimedelta> {
542542
bytes_as_timedelta(self, self.as_bytes(), microseconds_overflow_behavior)
543543
}
544-
#[cfg_attr(has_no_coverage, no_coverage)]
544+
#[cfg_attr(has_coverage_attribute, coverage(off))]
545545
fn strict_timedelta(
546546
&self,
547547
microseconds_overflow_behavior: speedate::MicrosecondsPrecisionOverflowBehavior,

0 commit comments

Comments
 (0)