Skip to content

Commit c14bb14

Browse files
rantamatti-lamppu
authored andcommitted
ruff: Automatic fixes from flake8-annotations ruleset
- Do not enable the ruleset yet, just have fix everything that it can fix automatically.
1 parent 094957d commit c14bb14

71 files changed

Lines changed: 141 additions & 125 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

actions/recurring_reservation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ class ReservationDetails(TypedDict, total=False):
107107

108108

109109
class RecurringReservationActions:
110-
def __init__(self, recurring_reservation: RecurringReservation):
110+
def __init__(self, recurring_reservation: RecurringReservation) -> None:
111111
self.recurring_reservation = recurring_reservation
112112

113113
def pre_calculate_slots(

actions/reservation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010

1111
class ReservationActions:
12-
def __init__(self, reservation: Reservation):
12+
def __init__(self, reservation: Reservation) -> None:
1313
self.reservation = reservation
1414

1515
def get_actual_before_buffer(self) -> datetime.timedelta:

actions/reservation_unit.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def _get_parent_resource_id(self) -> int | None:
106106
except (ExternalServiceError, KeyError, IndexError, TypeError):
107107
return None
108108

109-
def _create_hauki_resource(self, hauki_resource_data):
109+
def _create_hauki_resource(self, hauki_resource_data) -> None:
110110
"""Create a new HaukiResource in Hauki API for the ReservationUnit."""
111111
# New Hauki Resource, create it in Hauki API and update the reservation unit
112112
response_data: HaukiAPIResource = HaukiAPIClient.create_resource(data=hauki_resource_data)
@@ -117,7 +117,7 @@ def _create_hauki_resource(self, hauki_resource_data):
117117
self.reservation_unit.origin_hauki_resource = origin_hauki_resource
118118
self.reservation_unit.save()
119119

120-
def _update_hauki_resource(self, hauki_resource_data):
120+
def _update_hauki_resource(self, hauki_resource_data) -> None:
121121
"""Update the Hauki Resource in Hauki API with ReservationUnits data."""
122122
hauki_resource_data["id"] = self.reservation_unit.origin_hauki_resource.id
123123

@@ -126,7 +126,7 @@ def _update_hauki_resource(self, hauki_resource_data):
126126

127127

128128
class ReservationUnitActions(ReservationUnitHaukiExporter):
129-
def __init__(self, reservation_unit: ReservationUnit):
129+
def __init__(self, reservation_unit: ReservationUnit) -> None:
130130
self.reservation_unit = reservation_unit
131131

132132
def get_actual_before_buffer(

api/graphql/extensions/fields.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class ValidatingListField(serializers.ListField):
6363
before default implementation and provides better error messages
6464
"""
6565

66-
def __init__(self, *args, **kwargs):
66+
def __init__(self, *args, **kwargs) -> None:
6767
super().__init__(*args, **kwargs)
6868

6969
def run_child_validation(self, data):
@@ -84,7 +84,7 @@ class OldChoiceValidator:
8484
message = _('Choice "%(choice)s" is not allowed. Allowed choices are: %(allowed_choices)s.')
8585
code = "invalid_choice"
8686

87-
def __init__(self, allowed_choices):
87+
def __init__(self, allowed_choices) -> None:
8888
if len(allowed_choices) > 0 and isinstance(allowed_choices[0][0], int):
8989
self.allowed_choices = [choice[0] for choice in allowed_choices]
9090
else:
@@ -107,7 +107,7 @@ def __call__(self, value):
107107

108108

109109
class OldChoiceCharField(serializers.CharField):
110-
def __init__(self, choices, **kwargs):
110+
def __init__(self, choices, **kwargs) -> None:
111111
super().__init__(**kwargs)
112112
choice_validator = OldChoiceValidator(choices)
113113
self.validators.append(choice_validator)
@@ -127,7 +127,7 @@ def get_attribute(self, instance):
127127
class OldChoiceIntegerField(serializers.IntegerField):
128128
choices = None
129129

130-
def __init__(self, choices, **kwargs):
130+
def __init__(self, choices, **kwargs) -> None:
131131
super().__init__(**kwargs)
132132
choice_validator = OldChoiceValidator(choices)
133133
self.validators.append(choice_validator)

api/graphql/extensions/serializers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66

77
class OldPrimaryKeySerializerBase(serializers.ModelSerializer):
8-
def _check_id_list(self, id_list, field_name):
8+
def _check_id_list(self, id_list, field_name) -> None:
99
for identifier in id_list:
1010
try:
1111
int(identifier)

api/graphql/types/reservation/mutations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ class Meta:
139139
permission_classes = [ReservationPermission]
140140

141141
@classmethod
142-
def validate_deletion(cls, instance: Reservation, user: AnyUser):
142+
def validate_deletion(cls, instance: Reservation, user: AnyUser) -> None:
143143
if instance.state not in (
144144
ReservationStateChoice.CREATED.value,
145145
ReservationStateChoice.WAITING_FOR_PAYMENT.value,

api/graphql/types/reservation/serializers/adjust_time_serializers.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class Meta:
2626
"state",
2727
]
2828

29-
def __init__(self, *args, **kwargs):
29+
def __init__(self, *args, **kwargs) -> None:
3030
super().__init__(*args, **kwargs)
3131
self.fields["state"].readonly = True
3232

@@ -84,7 +84,7 @@ def validate(self, data):
8484

8585
return data
8686

87-
def check_begin(self, begin, end):
87+
def check_begin(self, begin, end) -> None:
8888
if begin > end:
8989
raise ValidationErrorWithCode(
9090
"End cannot be before begin",
@@ -126,7 +126,7 @@ def check_cancellation_rules(self, reservation_unit: ReservationUnit) -> None:
126126
ValidationErrorCodes.CANCELLATION_NOT_ALLOWED,
127127
)
128128

129-
def check_and_handle_pricing(self, data):
129+
def check_and_handle_pricing(self, data) -> None:
130130
if self.instance.price_net > 0:
131131
raise ValidationErrorWithCode(
132132
"Reservation time cannot be changed due to its price",

api/graphql/types/reservation/serializers/confirm_serializers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class ReservationConfirmSerializer(ReservationUpdateSerializer):
3434
),
3535
)
3636

37-
def __init__(self, *args, **kwargs):
37+
def __init__(self, *args, **kwargs) -> None:
3838
super().__init__(*args, **kwargs)
3939
# All fields should be read-only, except for the lookup
4040
# field (PK) which should be included in the input

api/graphql/types/reservation/serializers/create_serializers.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class Meta:
9797
"type",
9898
]
9999

100-
def __init__(self, *args, **kwargs):
100+
def __init__(self, *args, **kwargs) -> None:
101101
super().__init__(*args, **kwargs)
102102
self.fields["state"].read_only = True
103103
self.fields["reservation_unit_pks"].write_only = True
@@ -237,7 +237,7 @@ def _prefill_reservation_from_profile(self, data: dict[str, Any]) -> None:
237237
if value is not None:
238238
data[key] = value
239239

240-
def check_sku(self, current_sku, new_sku):
240+
def check_sku(self, current_sku, new_sku) -> None:
241241
if current_sku is not None and current_sku != new_sku:
242242
raise ValidationErrorWithCode(
243243
"An ambiguous SKU cannot be assigned for this reservation.",
@@ -261,14 +261,14 @@ def check_max_reservations_per_user(self, user: AnyUser, reservation_unit: Reser
261261
ValidationErrorCodes.MAX_NUMBER_OF_ACTIVE_RESERVATIONS_EXCEEDED,
262262
)
263263

264-
def check_reservation_kind(self, reservation_unit):
264+
def check_reservation_kind(self, reservation_unit) -> None:
265265
if reservation_unit.reservation_kind == ReservationKind.SEASON:
266266
raise ValidationErrorWithCode(
267267
"Reservation unit is only available or seasonal booking.",
268268
ValidationErrorCodes.RESERVATION_UNIT_TYPE_IS_SEASON,
269269
)
270270

271-
def check_reservation_type(self, user, reservation_unit_ids: list[int], reservation_type: str | None):
271+
def check_reservation_type(self, user, reservation_unit_ids: list[int], reservation_type: str | None) -> None:
272272
if reservation_type is None or can_handle_reservation_with_units(user, reservation_unit_ids):
273273
return
274274

api/graphql/types/reservation/serializers/memo_serializers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ class Meta:
77
model = Reservation
88
fields = ["pk", "working_memo"]
99

10-
def __init__(self, *args, **kwargs):
10+
def __init__(self, *args, **kwargs) -> None:
1111
super().__init__(*args, **kwargs)
1212
self.fields["pk"].help_text = "Primary key of the reservation"

0 commit comments

Comments
 (0)