Enable convenient typing of LocalSite-or-ALL parameters.

Review Request #13144 — Created July 13, 2023 and submitted

Information

Review Board
release-6.x

Reviewers

Review Board 5 introduced a LocalSite.ALL value, which could be used
to query state without considering a LocalSite value (as opposed to a
None value for the global site). This was a bit hard to type
correctly, and we ran the risk of different blocks of code attempting
their own typing.

This change introduces an AnyOrAllLocalSites type, which supports a
LocalSite instance, None, or ALL.

To make this work, ALL needed to be converted from a singleton object
to a value supported in Literal. The safest approach was to use an
enum (which won't unintentionally cast to a string or integer in a
query). So we now have a private enum with only an ALL value.

All unit tests pass.

Summary ID
Enable convenient typing of LocalSite-or-ALL parameters.
Review Board 5 introduced a `LocalSite.ALL` value, which could be used to query state without considering a `LocalSite` value (as opposed to a `None` value for the global site). This was a bit hard to type correctly, and we ran the risk of different blocks of code attempting their own typing. This change introduces an `AnyOrAllLocalSites` type, which supports a `LocalSite` instance, `None`, or `ALL`. To make this work, `ALL` needed to be converted from a singleton object to a value supported in `Literal`. The safest approach was to use an enum (which won't unintentionally cast to a string or integer in a query). So we now have a private enum with only an `ALL` value.
6b30c79b3751319859b45defba9002ad47e33abd
david
  1. Ship It!
  2. 
      
chipx86
Review request changed
Status:
Completed
Change Summary:
Pushed to release-6.x (6a767bc)