diff --git a/pyproject.toml b/pyproject.toml index a008c9e6a6..e8f9ca4b31 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -134,18 +134,13 @@ target-version = "py311" select = [ "B0", "B904", + "B909", "C4", "COM818", "D2", "D301", "D4", "E", - "E301", - "E302", - "E303", - "E304", - "E305", - "E306", "F", "FLY002", "ISC", @@ -157,11 +152,13 @@ select = [ "Q", "RUF", "SIM", + "SLOT", "UP", "W" ] ignore = [ "B007", + "C420", "D200", "D201", "D202", @@ -173,6 +170,7 @@ ignore = [ "D400", "D401", "D412", + "E226", "E402", "E711", "E712", @@ -182,18 +180,19 @@ ignore = [ "PYI041", "RUF012", "RUF013", - # TODO: We would like to enable some of these eventually - # But there are a lot of violations + "RUF021", + "RUF022", + "RUF023", + "RUF031", + # TODO: We would like to enable SIM102, but it has a ton of + # violations, so it's a big job to clean it up "SIM102", "SIM103", "SIM105", "SIM108", "SIM110", - "SIM113", - "SIM114", "SIM118", "SIM210", - "SIM211", "SIM910", "UP009", "UP012", @@ -204,19 +203,13 @@ ignore = [ unfixable = [] external = ["MS", "TC"] allowed-confusables = ["×"] -# NOTE: Enable preview rules, but only the ones we select explicitly preview = true -explicit-preview-rules = true [tool.ruff.lint.extend-per-file-ignores] "src/onegov/core/types.py" = ["B018"] "reportlab_settings.py" = ["N"] "*.pyi" = [ - "D", "E501", - # TODO: re-enable this one, I think it is smarter in Ruff - "F401", - "F403", "N", "Q", # NOTE: We would prefer to set a different target version instead diff --git a/src/onegov/activity/collections/booking.py b/src/onegov/activity/collections/booking.py index 4dd06d68be..e250fb0802 100644 --- a/src/onegov/activity/collections/booking.py +++ b/src/onegov/activity/collections/booking.py @@ -249,9 +249,7 @@ def cancel_booking( blocked = {b for b in bookings if b.state == 'blocked'} unblocked = set() - if booking.period.all_inclusive: - limit = booking.period.booking_limit - elif booking.period.booking_limit: + if booking.period.all_inclusive or booking.period.booking_limit: limit = booking.period.booking_limit else: limit = booking.attendee.limit diff --git a/src/onegov/activity/collections/invoice.py b/src/onegov/activity/collections/invoice.py index fd8b94f8fa..1bd619c6d8 100644 --- a/src/onegov/activity/collections/invoice.py +++ b/src/onegov/activity/collections/invoice.py @@ -33,7 +33,7 @@ def __init__( self.period_id = period_id if schema not in KNOWN_SCHEMAS: - raise RuntimeError('Unknown schema: {schema}') + raise RuntimeError(f'Unknown schema: {schema}') self.schema_name = schema self.schema_config = (schema_config or {}) diff --git a/src/onegov/agency/excel_export.py b/src/onegov/agency/excel_export.py index 10e044a625..da52aa57d4 100644 --- a/src/onegov/agency/excel_export.py +++ b/src/onegov/agency/excel_export.py @@ -65,16 +65,14 @@ def export_person_xlsx(session: 'Session') -> BytesIO: write_out = extract_person_data(session) - row = 0 - for entry in write_out: - row += 1 - for col_ix, value in enumerate(entry.values()): + for row, entry in enumerate(write_out, start=1): + for column, value in enumerate(entry.values()): if value is None: - worksheet.write_string(row, col_ix, '') + worksheet.write_string(row, column, '') elif isinstance(value, str): - worksheet.write_string(row, col_ix, value) + worksheet.write_string(row, column, value) elif isinstance(value, (int, Decimal)): - worksheet.write_number(row, col_ix, value) + worksheet.write_number(row, column, value) else: raise NotImplementedError() diff --git a/src/onegov/agency/layout.py b/src/onegov/agency/layout.py index 745b964680..91e0cad2e9 100644 --- a/src/onegov/agency/layout.py +++ b/src/onegov/agency/layout.py @@ -379,9 +379,7 @@ def get_ancestors( ) -> 'Iterator[Link]': for ix, ancestor in enumerate(item.ancestors, 1): - if levels is None: - yield Link(ancestor.title, self.request.link(ancestor)) - elif ix in levels: + if levels is None or ix in levels: yield Link(ancestor.title, self.request.link(ancestor)) if with_item: diff --git a/src/onegov/core/converters.py b/src/onegov/core/converters.py index 3fe8d76577..7d5a726686 100644 --- a/src/onegov/core/converters.py +++ b/src/onegov/core/converters.py @@ -114,7 +114,7 @@ def bool_decode(s: str) -> bool: ... def bool_decode(s: str) -> bool: """ Decodes a boolean. """ - return False if s == '0' or s == '' else True + return not (s == '0' or s == '') @overload diff --git a/src/onegov/core/i18n/__init__.py b/src/onegov/core/i18n/__init__.py index ea5bd87f58..ef9de14603 100644 --- a/src/onegov/core/i18n/__init__.py +++ b/src/onegov/core/i18n/__init__.py @@ -277,7 +277,7 @@ def get_translations( # it might be worth revisiting in the future if we can # enable caching here again, or introduce our own wtf = super().get_translations(form) - if wtf is None: + if wtf is None: wtf = gettext.NullTranslations() wtf.is_wtforms = True diff --git a/src/onegov/directory/archive.py b/src/onegov/directory/archive.py index 66e70f48ac..e82b888f24 100644 --- a/src/onegov/directory/archive.py +++ b/src/onegov/directory/archive.py @@ -42,7 +42,7 @@ ] class SupportsReadAndSeek(SupportsRead[bytes], Protocol): - def seek(self, __offset: int) -> object: ... + def seek(self, offset: int, /) -> object: ... class _Sentinel(Enum): diff --git a/src/onegov/directory/migration.py b/src/onegov/directory/migration.py index 175ea7d15f..0d0e8f8bce 100644 --- a/src/onegov/directory/migration.py +++ b/src/onegov/directory/migration.py @@ -365,16 +365,14 @@ def detect_renamed_fields(self) -> None: def detect_changed_fields(self) -> None: self.changed_fields = [] - for old in self.old: - if old in self.renamed_fields: - new = self.renamed_fields[old] - elif old in self.new: - new = old + for old_id, old in self.old.items(): + if old_id in self.renamed_fields: + new_id = self.renamed_fields[old_id] + elif old_id in self.new: + new_id = old_id else: continue - if self.old[old].required != self.new[new].required: - self.changed_fields.append(new) - - elif self.old[old].type != self.new[new].type: - self.changed_fields.append(new) + new = self.new[new_id] + if old.required != new.required or old.type != new.type: + self.changed_fields.append(new_id) diff --git a/src/onegov/election_day/formats/imports/election/wabstic_majorz.py b/src/onegov/election_day/formats/imports/election/wabstic_majorz.py index 89d438026c..acc23039ce 100644 --- a/src/onegov/election_day/formats/imports/election/wabstic_majorz.py +++ b/src/onegov/election_day/formats/imports/election/wabstic_majorz.py @@ -268,8 +268,7 @@ def import_election_wabstic_majorz( # Check if the entity is counted try: - entity['counted'] = False if validate_integer( - line, 'sperrung') == 0 else True + entity['counted'] = validate_integer(line, 'sperrung') != 0 except ValueError as e: line_errors.append(e.args[0]) diff --git a/src/onegov/election_day/formats/imports/election/wabstic_proporz.py b/src/onegov/election_day/formats/imports/election/wabstic_proporz.py index 12d40db02c..d005265b30 100644 --- a/src/onegov/election_day/formats/imports/election/wabstic_proporz.py +++ b/src/onegov/election_day/formats/imports/election/wabstic_proporz.py @@ -324,7 +324,7 @@ def import_election_wabstic_proporz( # From wabstic export docs: Einheit ist grün-gesperrt # (1442=14:42 Uhr von der Oberbehörde gesperrt), sonst leer locking_time = validate_integer(line, 'sperrung', default=False) - entity['counted'] = False if not locking_time else True + entity['counted'] = locking_time != 0 except ValueError as e: line_errors.append(e.args[0]) diff --git a/src/onegov/election_day/formats/imports/vote/wabstic.py b/src/onegov/election_day/formats/imports/vote/wabstic.py index dbc6d9050a..b07a8791bb 100644 --- a/src/onegov/election_day/formats/imports/vote/wabstic.py +++ b/src/onegov/election_day/formats/imports/vote/wabstic.py @@ -199,7 +199,7 @@ def import_vote_wabstic( # Check if the entity is counted try: counted_num = validate_integer(line, 'sperrung') - counted = False if counted_num == 0 else True + counted = counted_num != 0 except ValueError: line_errors.append(_('Invalid values')) else: diff --git a/src/onegov/election_day/path.py b/src/onegov/election_day/path.py index e188ecf44b..b6767611d9 100644 --- a/src/onegov/election_day/path.py +++ b/src/onegov/election_day/path.py @@ -320,7 +320,7 @@ def get_data_source_item( @ElectionDayApp.path( model=ArchivedResultCollection, - path='/archive/{date}' + path='/archive/{date}' # noqa: RUF027 ) def get_archive_by_year( app: ElectionDayApp, diff --git a/src/onegov/election_day/views/subscription.py b/src/onegov/election_day/views/subscription.py index 88dac167ea..6948f1e559 100644 --- a/src/onegov/election_day/views/subscription.py +++ b/src/onegov/election_day/views/subscription.py @@ -58,7 +58,7 @@ def subscribe_email( 'message': message, 'cancel': layout.homepage_link, 'callout': callout, - 'show_form': False if callout else True + 'show_form': not callout } @@ -145,7 +145,7 @@ def unsubscribe_email( 'title': _('Stop email subscription'), 'cancel': layout.homepage_link, 'callout': callout, - 'show_form': False if callout else True + 'show_form': not callout } @@ -246,7 +246,7 @@ def subscribe_sms( ), 'cancel': layout.homepage_link, 'callout': callout, - 'show_form': False if callout else True + 'show_form': not callout } @@ -288,5 +288,5 @@ def unsubscribe_sms( 'title': _('Stop SMS subscription'), 'cancel': layout.homepage_link, 'callout': callout, - 'show_form': False if callout else True + 'show_form': not callout } diff --git a/src/onegov/feriennet/views/booking.py b/src/onegov/feriennet/views/booking.py index 4bb964c546..b042e80037 100644 --- a/src/onegov/feriennet/views/booking.py +++ b/src/onegov/feriennet/views/booking.py @@ -300,14 +300,12 @@ def actions_by_booking( )) if period.active and period.confirmed and booking.state == 'accepted': - if layout.request.is_admin: - may_cancel = True - elif not booking.occasion.is_past_cancellation(layout.today()): - may_cancel = True - else: - may_cancel = False - - if may_cancel: + if ( + # admins can always cancel bookings + layout.request.is_admin + # other users can if it isn't past its cancellation deadline + or not booking.occasion.is_past_cancellation(layout.today()) + ): actions.append(Link( text=_('Cancel Booking'), url=layout.csrf_protected_url( diff --git a/src/onegov/form/collection.py b/src/onegov/form/collection.py index 7f8e9d0de5..8fe68b8d16 100644 --- a/src/onegov/form/collection.py +++ b/src/onegov/form/collection.py @@ -749,10 +749,10 @@ def add( submission_window = submission_window submission = SurveySubmission( - id = id or uuid4(), - name = name, - meta = meta or {}, - submission_window = submission_window + id=id or uuid4(), + name=name, + meta=meta or {}, + submission_window=submission_window ) # extensions are inherited from definitions diff --git a/src/onegov/form/fields.py b/src/onegov/form/fields.py index feff66b864..6c947bf44c 100644 --- a/src/onegov/form/fields.py +++ b/src/onegov/form/fields.py @@ -311,7 +311,7 @@ class UploadMultipleField(UploadMultipleBase, FileField): if TYPE_CHECKING: _separator: str - def _add_entry(self, __d: _MultiDictLikeWithGetlist) -> UploadField: + def _add_entry(self, d: _MultiDictLikeWithGetlist, /) -> UploadField: ... upload_field_class: type[UploadField] = UploadField diff --git a/src/onegov/form/types.py b/src/onegov/form/types.py index 0c1c381984..411798de6c 100644 --- a/src/onegov/form/types.py +++ b/src/onegov/form/types.py @@ -12,7 +12,7 @@ from wtforms.form import BaseForm class FieldCondition(Protocol[BaseFormT, FieldT]): - def __call__(self, __form: BaseFormT, __field: FieldT) -> bool: ... + def __call__(self, form: BaseFormT, field: FieldT, /) -> bool: ... Widget: TypeAlias = _Widget Filter: TypeAlias = _Filter diff --git a/src/onegov/form/utils.py b/src/onegov/form/utils.py index 3069248724..c43530f8ed 100644 --- a/src/onegov/form/utils.py +++ b/src/onegov/form/utils.py @@ -95,14 +95,13 @@ def __init__( assert self.step != Decimal(0) def __repr__(self) -> str: - if self.start <= self.stop and self.step == Decimal('1.0'): - return "decimal_range('{}', '{}')".format(self.start, self.stop) - elif self.start >= self.stop and self.step == Decimal('-1.0'): - return "decimal_range('{}', '{}')".format(self.start, self.stop) - else: - return "decimal_range('{}', '{}', '{}')".format( - self.start, self.stop, self.step - ) + if ( + (self.start <= self.stop and self.step == Decimal('1.0')) + or (self.start >= self.stop and self.step == Decimal('-1.0')) + ): + return f"decimal_range('{self.start}', '{self.stop}')" + + return f"decimal_range('{self.start}', '{self.stop}', '{self.step}')" def __eq__(self, other: object) -> bool: if not isinstance(other, self.__class__): diff --git a/src/onegov/fsi/ims_import.py b/src/onegov/fsi/ims_import.py index 376c74c504..3fe2a0960d 100644 --- a/src/onegov/fsi/ims_import.py +++ b/src/onegov/fsi/ims_import.py @@ -284,7 +284,7 @@ def import_teacher_data( def parse_completed(val: str | None) -> bool: - return False if val == 'N' else True + return val != 'N' @with_open diff --git a/src/onegov/landsgemeinde/path.py b/src/onegov/landsgemeinde/path.py index 4eebbdab13..c965aedf1c 100644 --- a/src/onegov/landsgemeinde/path.py +++ b/src/onegov/landsgemeinde/path.py @@ -27,7 +27,7 @@ def get_assemblies(app: LandsgemeindeApp) -> AssemblyCollection: @LandsgemeindeApp.path( model=Assembly, - path='/landsgemeinde/{date}', + path='/landsgemeinde/{date}', # noqa: RUF027 converters={'date': extended_date_converter} ) def get_assembly(app: LandsgemeindeApp, date: 'date') -> Assembly | None: @@ -36,7 +36,7 @@ def get_assembly(app: LandsgemeindeApp, date: 'date') -> Assembly | None: @LandsgemeindeApp.path( model=AgendaItemCollection, - path='/traktanden/{date}', + path='/traktanden/{date}', # noqa: RUF027 converters={'date': extended_date_converter} ) def get_agenda_items( diff --git a/src/onegov/landsgemeinde/views/opendata_swiss.py b/src/onegov/landsgemeinde/views/opendata_swiss.py index 333c643852..28dc105ab3 100644 --- a/src/onegov/landsgemeinde/views/opendata_swiss.py +++ b/src/onegov/landsgemeinde/views/opendata_swiss.py @@ -187,7 +187,7 @@ def set_headers(response: 'Response') -> None: url = request.link(item, 'json') sub(dist, 'dcat:accessURL', {'rdf:resource': url}) sub(dist, 'dcat:downloadURL', {'rdf:resource': url}) - sub( dist, 'dct:license', { + sub(dist, 'dct:license', { 'rdf:resource': 'http://dcat-ap.ch/vocabulary/licenses/terms_by' }) sub(dist, 'dcat:mediaType', { diff --git a/src/onegov/org/layout.py b/src/onegov/org/layout.py index 1450555647..753a0b9f96 100644 --- a/src/onegov/org/layout.py +++ b/src/onegov/org/layout.py @@ -599,9 +599,10 @@ def format_datetime_range( with_year: bool = False ) -> str: - if start.date() == end.date(): - show_single_day = True - elif (end - start) <= timedelta(hours=23) and end.time() < time(6, 0): + if start.date() == end.date() or ( + (end - start) <= timedelta(hours=23) + and end.time() < time(6, 0) + ): show_single_day = True else: show_single_day = False @@ -2324,7 +2325,7 @@ def format_recurrence(self, recurrence: str | None) -> str: def event_deletable(self, event: 'Event') -> bool: tickets = TicketCollection(self.request.session) ticket = tickets.by_handler_id(event.id.hex) - return False if ticket else True + return not ticket class OccurrencesLayout(DefaultLayout, EventLayoutMixin): diff --git a/src/onegov/org/models/extensions.py b/src/onegov/org/models/extensions.py index 202bcee751..7b66bade3c 100644 --- a/src/onegov/org/models/extensions.py +++ b/src/onegov/org/models/extensions.py @@ -590,7 +590,7 @@ class PersonForm(Form): 'data-placeholder': request.translate( _('Select additional person') ), - 'data-no_results_text':request.translate( + 'data-no_results_text': request.translate( _('No results match') ), } diff --git a/src/onegov/org/models/ticket.py b/src/onegov/org/models/ticket.py index 7871c7adea..f25e885e49 100644 --- a/src/onegov/org/models/ticket.py +++ b/src/onegov/org/models/ticket.py @@ -419,7 +419,7 @@ def payment(self) -> 'Payment | None': @property def deleted(self) -> bool: - return False if self.reservations else True + return not self.reservations @property def extra_data(self) -> list[str]: diff --git a/src/onegov/org/models/traitinfo.py b/src/onegov/org/models/traitinfo.py index b3c5217aae..076fd4956f 100644 --- a/src/onegov/org/models/traitinfo.py +++ b/src/onegov/org/models/traitinfo.py @@ -199,7 +199,7 @@ def get_edit_links( assert self.trait is not None trait_messages = self.trait_messages[self.trait] - safe_delete = False if self.children else True # type:ignore + safe_delete = not self.children # type:ignore if safe_delete or request.current_role == 'admin': diff --git a/src/onegov/org/views/allocation.py b/src/onegov/org/views/allocation.py index 39fe53b3c2..b258e04ef2 100644 --- a/src/onegov/org/views/allocation.py +++ b/src/onegov/org/views/allocation.py @@ -661,4 +661,3 @@ def handle_delete_rule(self: Resource, request: 'OrgRequest') -> None: 'n': count }) ) - diff --git a/src/onegov/org/views/form_submission.py b/src/onegov/org/views/form_submission.py index e9ba44c1db..b911334563 100644 --- a/src/onegov/org/views/form_submission.py +++ b/src/onegov/org/views/form_submission.py @@ -535,4 +535,3 @@ def handle_survey_submission( 'model': self, 'price': None, } - diff --git a/src/onegov/org/views/newsletter.py b/src/onegov/org/views/newsletter.py index 240fa0826c..f9737328c3 100644 --- a/src/onegov/org/views/newsletter.py +++ b/src/onegov/org/views/newsletter.py @@ -750,4 +750,3 @@ def import_newsletter_recipients( 'form': form, 'form_width': 'large', } - diff --git a/src/onegov/pay/types.py b/src/onegov/pay/types.py index a93914f418..7444c17fd7 100644 --- a/src/onegov/pay/types.py +++ b/src/onegov/pay/types.py @@ -15,10 +15,11 @@ class PriceDict(TypedDict): credit_card_payment: bool class FeePolicy(Protocol): - def from_amount(self, __amount: Decimal | float) -> Decimal | float: + def from_amount(self, amount: Decimal | float, /) -> Decimal | float: ... - def compensate(self, __amount: Decimal | float) -> Decimal | float: ... + def compensate(self, amount: Decimal | float, /) -> Decimal | float: + ... # NOTE: We would like to use intersections here than pseudo classes @type_check_only diff --git a/src/onegov/search/indexer.py b/src/onegov/search/indexer.py index b72fccd40b..067e62849d 100644 --- a/src/onegov/search/indexer.py +++ b/src/onegov/search/indexer.py @@ -473,8 +473,7 @@ def task_generator() -> 'Iterator[IndexTask]': if action == 'index': self.index(task_list, session) else: - raise NotImplementedError("Action '{action}' not " - 'implemented') + raise NotImplementedError(f"Action '{action}' not implemented") class TypeMapping: diff --git a/src/onegov/swissvotes/collections/votes.py b/src/onegov/swissvotes/collections/votes.py index 859c9edfb1..4d357d4255 100644 --- a/src/onegov/swissvotes/collections/votes.py +++ b/src/onegov/swissvotes/collections/votes.py @@ -577,17 +577,15 @@ def export_xlsx(self, file: IO[str]) -> None: query = self.query() query = query.order_by(None).order_by(SwissVote.bfs_number) - row = 0 - for vote in query: - row += 1 - for column_, value in enumerate(mapper.get_values(vote)): + for row, vote in enumerate(query, start=1): + for column, value in enumerate(mapper.get_values(vote)): if value is None: pass elif isinstance(value, str): - worksheet.write_string(row, column_, value) + worksheet.write_string(row, column, value) elif isinstance(value, date): - worksheet.write_datetime(row, column_, value) + worksheet.write_datetime(row, column, value) elif isinstance(value, (int, Decimal)): - worksheet.write_number(row, column_, value) + worksheet.write_number(row, column, value) workbook.close() diff --git a/src/onegov/translator_directory/forms/language.py b/src/onegov/translator_directory/forms/language.py index 575ceaf1f6..67098f635b 100644 --- a/src/onegov/translator_directory/forms/language.py +++ b/src/onegov/translator_directory/forms/language.py @@ -16,14 +16,16 @@ class LanguageForm(Form): ) def validate_name(self, field: StringField) -> None: - query = self.request.session.query(Language) - lang = query.filter_by(name=field.data).first() - if isinstance(self.model, LanguageCollection) and lang: - raise ValidationError( - _('${language} already exists', - mapping={'language': field.data}) - ) - elif lang and not lang.id == self.model.id: + query = self.request.session.query(Language.id) + row = query.filter_by(name=field.data).first() + if not row: + return + + lang_id, = row + if ( + isinstance(self.model, LanguageCollection) + or lang_id != self.model.id + ): raise ValidationError( _('${language} already exists', mapping={'language': field.data}) diff --git a/src/onegov/translator_directory/utils.py b/src/onegov/translator_directory/utils.py index a43236915d..a00a39c47e 100644 --- a/src/onegov/translator_directory/utils.py +++ b/src/onegov/translator_directory/utils.py @@ -146,9 +146,8 @@ def update_drive_distances( routes_found += 1 dist = parse_directions_result(response) if out_of_tolerance( - trs.drive_distance, dist, tolerance_factor, max_tolerance): - tol_failed.append((trs, dist)) - elif max_distance and dist > max_distance: + trs.drive_distance, dist, tolerance_factor, max_tolerance + ) or (max_distance and dist > max_distance): tol_failed.append((trs, dist)) else: trs.drive_distance = dist diff --git a/stubs/dectate/config.pyi b/stubs/dectate/config.pyi index 260a1e7f76..b76eadf8f5 100644 --- a/stubs/dectate/config.pyi +++ b/stubs/dectate/config.pyi @@ -1,5 +1,5 @@ import abc -from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence +from collections.abc import Callable, Iterable, Iterator from types import FrameType, TracebackType from typing import Any, ClassVar, TypeVar from typing_extensions import ParamSpec diff --git a/stubs/depot/io/interfaces.pyi b/stubs/depot/io/interfaces.pyi index 53263deae7..65adacfaf4 100644 --- a/stubs/depot/io/interfaces.pyi +++ b/stubs/depot/io/interfaces.pyi @@ -4,7 +4,7 @@ from cgi import FieldStorage from collections.abc import Callable, Iterable from datetime import datetime from io import IOBase -from typing import Any, IO, Protocol, Literal +from typing import IO from typing_extensions import TypeAlias from depot.io.utils import FileIntent as FileIntent diff --git a/stubs/depot/manager.pyi b/stubs/depot/manager.pyi index 5b58ef3fb0..cfb6e77960 100644 --- a/stubs/depot/manager.pyi +++ b/stubs/depot/manager.pyi @@ -1,6 +1,6 @@ from _typeshed import StrPath from _typeshed.wsgi import WSGIApplication -from typing import Any, Protocol +from typing import Any from depot.io.interfaces import FileStorage, StoredFile from depot.middleware import DepotMiddleware diff --git a/stubs/more/webassets/core.pyi b/stubs/more/webassets/core.pyi index e5a9d89ae7..a46a59b16d 100644 --- a/stubs/more/webassets/core.pyi +++ b/stubs/more/webassets/core.pyi @@ -1,5 +1,4 @@ from collections.abc import Callable -from typing import Any from dectate import directive from more.webassets import directives diff --git a/stubs/more/webassets/directives.pyi b/stubs/more/webassets/directives.pyi index 66a585005a..af3e657ee2 100644 --- a/stubs/more/webassets/directives.pyi +++ b/stubs/more/webassets/directives.pyi @@ -1,6 +1,5 @@ from _typeshed import StrOrBytesPath from collections.abc import Callable, Collection, Iterator, Mapping, Sequence -from typing import Any from typing_extensions import Self, TypeAlias from dectate import Action diff --git a/stubs/morepath/authentication.pyi b/stubs/morepath/authentication.pyi index 80f9e3034b..56e948a7b3 100644 --- a/stubs/morepath/authentication.pyi +++ b/stubs/morepath/authentication.pyi @@ -1,7 +1,4 @@ import abc -from typing import Any -from typing_extensions import TypeAlias -from uuid import UUID from .request import Request, Response diff --git a/stubs/morepath/directive.pyi b/stubs/morepath/directive.pyi index 07a80f3613..a8dbf44396 100644 --- a/stubs/morepath/directive.pyi +++ b/stubs/morepath/directive.pyi @@ -7,9 +7,8 @@ from typing_extensions import TypeAlias from webob import Response as BaseResponse import dectate -from dectate.sentinel import Sentinel from morepath.authentication import Identity, NoIdentity -from morepath.converter import Converter, ConverterRegistry +from morepath.converter import ConverterRegistry from morepath.path import PathRegistry # type:ignore[import-untyped] from morepath.predicate import PredicateRegistry # type:ignore[import-untyped] from morepath.request import Request diff --git a/stubs/reg/dispatch.pyi b/stubs/reg/dispatch.pyi index 90307346ba..9ac3e3ec67 100644 --- a/stubs/reg/dispatch.pyi +++ b/stubs/reg/dispatch.pyi @@ -1,6 +1,6 @@ from collections.abc import Callable, Iterator, Sequence from inspect import FullArgSpec -from typing import Any, Generic, NamedTuple, Protocol, TypeVar +from typing import Any, Generic, NamedTuple, TypeVar from typing_extensions import ParamSpec, TypeAlias from reg.predicate import Predicate, PredicateRegistry diff --git a/stubs/sqlalchemy_utils/i18n.pyi b/stubs/sqlalchemy_utils/i18n.pyi index 37a02987b3..887ce670ff 100644 --- a/stubs/sqlalchemy_utils/i18n.pyi +++ b/stubs/sqlalchemy_utils/i18n.pyi @@ -1,5 +1,5 @@ from collections.abc import Callable, Mapping -from typing import Any, Generic, Any as Incomplete +from typing import Any, Any as Incomplete from typing_extensions import TypeAlias from babel import Locale diff --git a/stubs/sqlalchemy_utils/observer.pyi b/stubs/sqlalchemy_utils/observer.pyi index d1c47940f2..405bb68577 100644 --- a/stubs/sqlalchemy_utils/observer.pyi +++ b/stubs/sqlalchemy_utils/observer.pyi @@ -2,8 +2,8 @@ from _typeshed import Incomplete from collections.abc import Callable, Collection, Iterable, Iterator from sqlalchemy.orm import Mapper, Session from sqlalchemy.orm.session import UOWTransaction # type:ignore[attr-defined] -from typing import Any, NamedTuple, TypeVar -from typing_extensions import ParamSpec, Never, TypeAlias +from typing import Any, NamedTuple +from typing_extensions import Never, TypeAlias _CallbackArgs: TypeAlias = tuple[Any, Callable[..., Any], list[Any]] diff --git a/stubs/transaction/_manager.pyi b/stubs/transaction/_manager.pyi index 852cae21e1..c33b121a2d 100644 --- a/stubs/transaction/_manager.pyi +++ b/stubs/transaction/_manager.pyi @@ -3,7 +3,7 @@ from collections.abc import Callable, Iterator from typing import ClassVar, TypeVar, overload from transaction._transaction import Savepoint, Transaction -from transaction.interfaces import ISynchronizer, ITransactionManager, _Attempt +from transaction.interfaces import ISynchronizer _T = TypeVar("_T") diff --git a/stubs/wtforms/form.pyi b/stubs/wtforms/form.pyi index c2a654073f..a0ebab70c3 100644 --- a/stubs/wtforms/form.pyi +++ b/stubs/wtforms/form.pyi @@ -1,6 +1,6 @@ from _typeshed import SupportsItems from collections.abc import Iterable, Iterator, Mapping, Sequence -from typing import Any, ClassVar, Protocol, TypeVar, overload +from typing import Any, Protocol, TypeVar, overload from typing_extensions import TypeAlias from wtforms.fields.core import Field, UnboundField diff --git a/stubs/wtforms/utils.pyi b/stubs/wtforms/utils.pyi index 530b44fdfc..ded0e7bc7e 100644 --- a/stubs/wtforms/utils.pyi +++ b/stubs/wtforms/utils.pyi @@ -1,5 +1,5 @@ from collections.abc import Iterable, Iterator -from typing import Any, Generic, Literal +from typing import Any, Literal from wtforms.meta import _MultiDictLikeWithGetall diff --git a/stubs/zope/sqlalchemy/datamanager.pyi b/stubs/zope/sqlalchemy/datamanager.pyi index 250fd9ded0..42baeb6deb 100644 --- a/stubs/zope/sqlalchemy/datamanager.pyi +++ b/stubs/zope/sqlalchemy/datamanager.pyi @@ -1,10 +1,10 @@ from collections.abc import Callable from typing import Any, Final, Literal -from typing_extensions import Self, TypeAlias +from typing_extensions import TypeAlias from sqlalchemy.engine import Connection from sqlalchemy.orm import Session -from transaction.interfaces import IDataManagerSavepoint, ISavepointDataManager, ITransaction, ITransactionManager +from transaction.interfaces import ITransaction, ITransactionManager _Status: TypeAlias = Literal["active", "changed", "readonly"] # TODO: Replace these with the proper types after SQLAlchemy 2.0 upgrade diff --git a/tests/onegov/org/test_extensions.py b/tests/onegov/org/test_extensions.py index bd52f68457..8f59574ea8 100644 --- a/tests/onegov/org/test_extensions.py +++ b/tests/onegov/org/test_extensions.py @@ -215,8 +215,8 @@ class TopicForm(Form): field = form.people field.append_entry() assert len(field) == 2 - field[0].form.person.data ='6d120102d90344868eb32614cf3acb1a' - field[1].form.person.data ='f0281b558a5f43f6ac81589d79538a87' + field[0].form.person.data = '6d120102d90344868eb32614cf3acb1a' + field[1].form.person.data = 'f0281b558a5f43f6ac81589d79538a87' form.populate_obj(topic) # the people are kept sorted by lastname, firstname by default