Files
Stephen Finucane 4de6e790fb Allow typing-related object imports
While our "no object imports" rule makes sense in most cases, it has
proven impractical when it comes to typing. Attempts to enforce this
here have resulted is absurdly long and difficult to comprehend function
signatures, or have necessitated unintuitive import aliasing. For
example, contrast:

    def process(
        data: collections.abc.Sequence[
            dict[str, collections.abc.Iterable[str]]
        ] | None = None,
    ) -> None: ...

with:

    def process(data: Sequence[dict[str, Iterable[str]]]) -> None:

We already gave exceptions for sqlalchemy, sqlalchemy-migrate, and i18n
packages to prevent code like this:

    query = query.filter(
        sql.or_(
          models.Foo.deleted == sql.false(), models.Bar.deleted.is_(None)
        )
    )
    if not query.count():
        msg = i18n._("a really bad error")
        raise Exception(msg)

rather than the more pleasing (and typical):

    query = query.filter(
        or_(models.Foo.deleted == sql.false(), models.Bar.deleted.is_(None))
    )
    if not query.count():
        msg = _("a really bad error")
        raise Exception(msg)

So this is merely a continuation.

While here, we also remove sqlalchemy-migrate from the list of
exceptions. No one is using this anymore since it doesn't support
sqlalchemy 2.x and has gone end-of-life.

Change-Id: Ifc45876e3d3655bca66ca5eb6d585a03cd15ab8d
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2026-03-09 13:00:59 +00:00
..
2026-03-09 13:00:59 +00:00
2022-01-10 17:10:15 +08:00