Skip to content

Commit f2f87c1

Browse files
authored
Merge pull request #4564 from jorenham/@overload-decorators
Remove redundant decorators on individual `@overload`s
2 parents bc2efa2 + bc8d15a commit f2f87c1

File tree

4 files changed

+38
-26
lines changed

4 files changed

+38
-26
lines changed

hypothesis-python/RELEASE.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
RELEASE_TYPE: patch
2+
3+
Clean up internal ``@overload`` type annotations.

hypothesis-python/src/hypothesis/extra/numpy.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,6 @@ def fill_for(elements, unique, fill, name=""):
419419

420420

421421
@overload
422-
@defines_strategy(force_reusable_values=True)
423422
def arrays(
424423
dtype: Union["np.dtype[G]", st.SearchStrategy["np.dtype[G]"]],
425424
shape: Union[int, st.SearchStrategy[int], Shape, st.SearchStrategy[Shape]],
@@ -431,7 +430,6 @@ def arrays(
431430

432431

433432
@overload
434-
@defines_strategy(force_reusable_values=True)
435433
def arrays(
436434
dtype: Union[D, st.SearchStrategy[D]],
437435
shape: Union[int, st.SearchStrategy[int], Shape, st.SearchStrategy[Shape]],
@@ -625,7 +623,6 @@ def dtype_factory(kind, sizes, valid_sizes, endianness):
625623

626624

627625
@overload
628-
@defines_dtype_strategy
629626
def unsigned_integer_dtypes(
630627
*,
631628
endianness: str = "?",
@@ -634,7 +631,6 @@ def unsigned_integer_dtypes(
634631

635632

636633
@overload
637-
@defines_dtype_strategy
638634
def unsigned_integer_dtypes(
639635
*,
640636
endianness: str = "?",
@@ -643,7 +639,6 @@ def unsigned_integer_dtypes(
643639

644640

645641
@overload
646-
@defines_dtype_strategy
647642
def unsigned_integer_dtypes(
648643
*,
649644
endianness: str = "?",
@@ -652,7 +647,6 @@ def unsigned_integer_dtypes(
652647

653648

654649
@overload
655-
@defines_dtype_strategy
656650
def unsigned_integer_dtypes(
657651
*,
658652
endianness: str = "?",
@@ -661,7 +655,6 @@ def unsigned_integer_dtypes(
661655

662656

663657
@overload
664-
@defines_dtype_strategy
665658
def unsigned_integer_dtypes(
666659
*,
667660
endianness: str = "?",
@@ -693,7 +686,6 @@ def unsigned_integer_dtypes(
693686

694687

695688
@overload
696-
@defines_dtype_strategy
697689
def integer_dtypes(
698690
*,
699691
endianness: str = "?",
@@ -702,7 +694,6 @@ def integer_dtypes(
702694

703695

704696
@overload
705-
@defines_dtype_strategy
706697
def integer_dtypes(
707698
*,
708699
endianness: str = "?",
@@ -711,7 +702,6 @@ def integer_dtypes(
711702

712703

713704
@overload
714-
@defines_dtype_strategy
715705
def integer_dtypes(
716706
*,
717707
endianness: str = "?",
@@ -720,7 +710,6 @@ def integer_dtypes(
720710

721711

722712
@overload
723-
@defines_dtype_strategy
724713
def integer_dtypes(
725714
*,
726715
endianness: str = "?",
@@ -729,7 +718,6 @@ def integer_dtypes(
729718

730719

731720
@overload
732-
@defines_dtype_strategy
733721
def integer_dtypes(
734722
*,
735723
endianness: str = "?",
@@ -757,7 +745,6 @@ def integer_dtypes(
757745

758746

759747
@overload
760-
@defines_dtype_strategy
761748
def floating_dtypes(
762749
*,
763750
endianness: str = "?",
@@ -766,7 +753,6 @@ def floating_dtypes(
766753

767754

768755
@overload
769-
@defines_dtype_strategy
770756
def floating_dtypes(
771757
*,
772758
endianness: str = "?",
@@ -775,7 +761,6 @@ def floating_dtypes(
775761

776762

777763
@overload
778-
@defines_dtype_strategy
779764
def floating_dtypes(
780765
*,
781766
endianness: str = "?",
@@ -784,7 +769,6 @@ def floating_dtypes(
784769

785770

786771
@overload
787-
@defines_dtype_strategy
788772
def floating_dtypes(
789773
*,
790774
endianness: str = "?",
@@ -793,7 +777,6 @@ def floating_dtypes(
793777

794778

795779
@overload
796-
@defines_dtype_strategy
797780
def floating_dtypes(
798781
*,
799782
endianness: str = "?",
@@ -822,7 +805,6 @@ def floating_dtypes(
822805

823806

824807
@overload
825-
@defines_dtype_strategy
826808
def complex_number_dtypes(
827809
*,
828810
endianness: str = "?",
@@ -831,7 +813,6 @@ def complex_number_dtypes(
831813

832814

833815
@overload
834-
@defines_dtype_strategy
835816
def complex_number_dtypes(
836817
*,
837818
endianness: str = "?",
@@ -840,7 +821,6 @@ def complex_number_dtypes(
840821

841822

842823
@overload
843-
@defines_dtype_strategy
844824
def complex_number_dtypes(
845825
*,
846826
endianness: str = "?",
@@ -849,7 +829,6 @@ def complex_number_dtypes(
849829

850830

851831
@overload
852-
@defines_dtype_strategy
853832
def complex_number_dtypes(
854833
*,
855834
endianness: str = "?",
@@ -1175,7 +1154,6 @@ def basic_indices(
11751154

11761155

11771156
@overload
1178-
@defines_strategy()
11791157
def integer_array_indices(
11801158
shape: Shape,
11811159
*,
@@ -1184,7 +1162,6 @@ def integer_array_indices(
11841162

11851163

11861164
@overload
1187-
@defines_strategy()
11881165
def integer_array_indices(
11891166
shape: Shape,
11901167
*,

hypothesis-python/tests/watchdog/test_database.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,17 +119,25 @@ def test_database_listener_directory_explicit(tmp_path):
119119
def listener(event):
120120
events.append(event)
121121

122+
time_sleep(0.1)
122123
db.add_listener(listener)
124+
time_sleep(0.1)
123125

124126
db.save(b"k1", b"v1")
125-
wait_for(lambda: events == [("save", (b"k1", b"v1"))], timeout=60)
127+
wait_for(lambda: events == [("save", (b"k1", b"v1"))], timeout=30)
126128

129+
time_sleep(0.1)
127130
db.remove_listener(listener)
131+
time_sleep(0.1)
132+
128133
db.delete(b"k1", b"v1")
129134
db.save(b"k1", b"v2")
130-
wait_for(lambda: events == [("save", (b"k1", b"v1"))], timeout=60)
135+
wait_for(lambda: events == [("save", (b"k1", b"v1"))], timeout=30)
131136

137+
time_sleep(0.1)
132138
db.add_listener(listener)
139+
time_sleep(0.1)
140+
133141
db.delete(b"k1", b"v2")
134142
db.save(b"k1", b"v3")
135143
wait_for(

tooling/src/hypothesistooling/__main__.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,31 @@ def check_format():
265265
print(f"{f} has incorrect start {start!r}", file=sys.stderr)
266266
bad = True
267267
assert not bad
268-
check_not_changed()
268+
try:
269+
check_not_changed()
270+
except Exception:
271+
box_width = 50
272+
inner_width = box_width - 2
273+
content_width = inner_width - 2
274+
msg1 = "Note: code differed after formatting."
275+
msg2 = "To fix this, run:"
276+
msg3 = " ./build.sh format"
277+
278+
lines = [
279+
"",
280+
" " + "*" * box_width,
281+
" *" + " " * inner_width + "*",
282+
" * " + msg1 + " " * (content_width - len(msg1)) + "*",
283+
" *" + " " * inner_width + "*",
284+
" * " + msg2 + " " * (content_width - len(msg2)) + "*",
285+
" *" + " " * inner_width + "*",
286+
" * " + msg3 + " " * (content_width - len(msg3)) + "*",
287+
" *" + " " * inner_width + "*",
288+
" " + "*" * box_width,
289+
"",
290+
]
291+
print("\n".join(lines), file=sys.stderr)
292+
raise
269293

270294

271295
def check_not_changed():

0 commit comments

Comments
 (0)