Skip to content

Commit d5804f3

Browse files
authored
Run prek run -a on main branch (#643)
2 parents 86d1647 + 9957c0f commit d5804f3

4 files changed

Lines changed: 52 additions & 30 deletions

File tree

spy/libspy/include/spy/operator.h

Lines changed: 40 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -614,11 +614,14 @@ spy_operator$bool_not(bool x) {
614614
// Power operations
615615
static inline int8_t
616616
spy_operator$i8_pow(int8_t base, int8_t exp) {
617-
if (exp == 0) return 1;
617+
if (exp == 0)
618+
return 1;
618619
if (exp < 0) {
619620
if (base == 0) {
620-
spy_panic("ZeroDivisionError", "0 cannot be raised to a negative power",
621-
__FILE__, __LINE__);
621+
spy_panic(
622+
"ZeroDivisionError", "0 cannot be raised to a negative power", __FILE__,
623+
__LINE__
624+
);
622625
}
623626
spy_panic("ValueError", "integer ** negative exponent", __FILE__, __LINE__);
624627
}
@@ -629,7 +632,8 @@ spy_operator$i8_pow(int8_t base, int8_t exp) {
629632
int8_t e = exp;
630633

631634
while (e > 0) {
632-
if (e & 1) result *= b;
635+
if (e & 1)
636+
result *= b;
633637
b *= b;
634638
e >>= 1;
635639
}
@@ -638,14 +642,16 @@ spy_operator$i8_pow(int8_t base, int8_t exp) {
638642

639643
static inline uint8_t
640644
spy_operator$u8_pow(uint8_t base, uint8_t exp) {
641-
if (exp == 0) return 1;
645+
if (exp == 0)
646+
return 1;
642647

643648
uint8_t result = 1;
644649
uint8_t b = base;
645650
uint8_t e = exp;
646651

647652
while (e > 0) {
648-
if (e & 1) result *= b;
653+
if (e & 1)
654+
result *= b;
649655
b *= b;
650656
e >>= 1;
651657
}
@@ -654,11 +660,14 @@ spy_operator$u8_pow(uint8_t base, uint8_t exp) {
654660

655661
static inline int32_t
656662
spy_operator$i32_pow(int32_t base, int32_t exp) {
657-
if (exp == 0) return 1;
663+
if (exp == 0)
664+
return 1;
658665
if (exp < 0) {
659666
if (base == 0) {
660-
spy_panic("ZeroDivisionError", "0 cannot be raised to a negative power",
661-
__FILE__, __LINE__);
667+
spy_panic(
668+
"ZeroDivisionError", "0 cannot be raised to a negative power", __FILE__,
669+
__LINE__
670+
);
662671
}
663672
spy_panic("ValueError", "integer ** negative exponent", __FILE__, __LINE__);
664673
}
@@ -669,7 +678,8 @@ spy_operator$i32_pow(int32_t base, int32_t exp) {
669678
int32_t e = exp;
670679

671680
while (e > 0) {
672-
if (e & 1) result *= b;
681+
if (e & 1)
682+
result *= b;
673683
b *= b;
674684
e >>= 1;
675685
}
@@ -678,14 +688,16 @@ spy_operator$i32_pow(int32_t base, int32_t exp) {
678688

679689
static inline uint32_t
680690
spy_operator$u32_pow(uint32_t base, uint32_t exp) {
681-
if (exp == 0) return 1;
691+
if (exp == 0)
692+
return 1;
682693

683694
uint32_t result = 1;
684695
uint32_t b = base;
685696
uint32_t e = exp;
686697

687698
while (e > 0) {
688-
if (e & 1) result *= b;
699+
if (e & 1)
700+
result *= b;
689701
b *= b;
690702
e >>= 1;
691703
}
@@ -694,11 +706,14 @@ spy_operator$u32_pow(uint32_t base, uint32_t exp) {
694706

695707
static inline int64_t
696708
spy_operator$i64_pow(int64_t base, int64_t exp) {
697-
if (exp == 0) return 1;
709+
if (exp == 0)
710+
return 1;
698711
if (exp < 0) {
699712
if (base == 0) {
700-
spy_panic("ZeroDivisionError", "0 cannot be raised to a negative power",
701-
__FILE__, __LINE__);
713+
spy_panic(
714+
"ZeroDivisionError", "0 cannot be raised to a negative power", __FILE__,
715+
__LINE__
716+
);
702717
}
703718
spy_panic("ValueError", "integer ** negative exponent", __FILE__, __LINE__);
704719
}
@@ -709,7 +724,8 @@ spy_operator$i64_pow(int64_t base, int64_t exp) {
709724
int64_t e = exp;
710725

711726
while (e > 0) {
712-
if (e & 1) result *= b;
727+
if (e & 1)
728+
result *= b;
713729
b *= b;
714730
e >>= 1;
715731
}
@@ -718,14 +734,16 @@ spy_operator$i64_pow(int64_t base, int64_t exp) {
718734

719735
static inline uint64_t
720736
spy_operator$u64_pow(uint64_t base, uint64_t exp) {
721-
if (exp == 0) return 1;
737+
if (exp == 0)
738+
return 1;
722739

723740
uint64_t result = 1;
724741
uint64_t b = base;
725742
uint64_t e = exp;
726743

727744
while (e > 0) {
728-
if (e & 1) result *= b;
745+
if (e & 1)
746+
result *= b;
729747
b *= b;
730748
e >>= 1;
731749
}
@@ -735,8 +753,10 @@ spy_operator$u64_pow(uint64_t base, uint64_t exp) {
735753
static inline double
736754
spy_operator$f64_pow(double x, double y) {
737755
if (x == 0.0 && y < 0.0) {
738-
spy_panic("ZeroDivisionError", "0.0 cannot be raised to a negative power",
739-
__FILE__, __LINE__);
756+
spy_panic(
757+
"ZeroDivisionError", "0.0 cannot be raised to a negative power", __FILE__,
758+
__LINE__
759+
);
740760
}
741761
if (x < 0.0 && isfinite(y) && y != trunc(y)) {
742762
spy_panic("ValueError", "math domain error", __FILE__, __LINE__);

spy/libspy/include/spy/unsafe.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ spy_gc_alloc_bdwgc(size_t size) {
5757
return (PTR){p}; \
5858
} \
5959
static inline PTR PTR##$alloc(size_t n) { \
60-
return (PTR){(T*)spy_##MEMKIND##_alloc(sizeof(T) * n)}; \
60+
return (PTR){(T *)spy_##MEMKIND##_alloc(sizeof(T) * n)}; \
6161
} \
6262
static inline T PTR##$deref(PTR p) { \
6363
return *(p.p); \
@@ -86,7 +86,7 @@ spy_gc_alloc_bdwgc(size_t size) {
8686
return (PTR){p, 1}; \
8787
} \
8888
static inline PTR PTR##$alloc(size_t n) { \
89-
return (PTR){(T*)spy_##MEMKIND##_alloc(sizeof(T) * n), (ptrdiff_t) n}; \
89+
return (PTR){(T *)spy_##MEMKIND##_alloc(sizeof(T) * n), (ptrdiff_t)n}; \
9090
} \
9191
static inline T PTR##$deref(PTR p) { \
9292
return *(p.p); \

spy/libspy/src/operator.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,10 @@ spy_operator$f32_ge(float x, float y) {
123123
float
124124
spy_operator$f32_pow(float x, float y) {
125125
if (x == 0.0f && y < 0.0f) {
126-
spy_panic("ZeroDivisionError", "0.0 cannot be raised to a negative power",
127-
__FILE__, __LINE__);
126+
spy_panic(
127+
"ZeroDivisionError", "0.0 cannot be raised to a negative power", __FILE__,
128+
__LINE__
129+
);
128130
}
129131
// Use __builtin_isfinite instead of isfinite: workaround for
130132
// https://github.com/emscripten-core/emscripten/issues/27418

stdlib/_str.spy

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -656,34 +656,34 @@ def _split_whitespace(self:str) -> list[str]:
656656
result.append(StrObject.to_str(llnew))
657657

658658
return result
659-
659+
660660

661661
@struct
662662
class unicode_codepoints:
663663
"""Iterates over the unicode codepoints in a string."""
664664
str: gc_ptr[StrObject]
665-
665+
666666
def __fastiter__(self) -> unicode_codepoints_iterator:
667667
return unicode_codepoints_iterator(self.str, 0)
668668

669669
@struct
670670
class unicode_codepoints_iterator:
671671
str_ptr: gc_ptr[StrObject]
672672
i: int
673-
673+
674674
def __next__(self) -> unicode_codepoints_iterator:
675675
return unicode_codepoints_iterator(self.str_ptr, self.i + self.__item_len())
676-
676+
677677
def __item__(self) -> i32:
678678
current_byte = self.str_ptr.utf8[self.i]
679679
codepoint: i32 = current_byte & __first_byte_mask(current_byte)
680680

681681
for j in range(self.__item_len() - 1):
682682
current_byte = self.str_ptr.utf8[self.i + j + 1] & u8(0b0011_1111)
683683
codepoint = i32(current_byte) | (codepoint << 6)
684-
684+
685685
return codepoint
686-
686+
687687
# the opposite of StopIteration :)
688688
def __continue_iteration__(self) -> bool:
689689
return self.i < self.str_ptr.length

0 commit comments

Comments
 (0)