"python.analysis.typeCheckingMode": "strict"Python Flag enums support setting an enum to the combination of other already defined enums using the | (OR) operator. This behaviour is shown in the documentation.
Pylance should not be flagging this as unsupported and marking the resulting value as an Unknown type. The resulting type should be along the lines of Literal[PinMode.INPUT | PinMode.OUTPUT] or Literal[PinMode[INPUT | OUTPUT]] (I think).
Pylance reports an error reportGeneralTypeIssues when using the | (OR) operator on flag type enums.
class PinMode(enum.Flag):
""" Pin operating mode """
INPUT = enum.auto()
OUTPUT = enum.auto()
DIGITAL = INPUT | OUTPUT # <-- this line gives the below error message
Operator "|" not supported for types "Literal[PinMode.INPUT]" and "Literal[PinMode.OUTPUT]"
Operator "|" not supported for types "Literal[PinMode.INPUT]" and "Literal[PinMode.OUTPUT]"Pylance(reportGeneralTypeIssues)
Thanks for the bug report. This will be fixed in the next release.
This issue has been fixed in version 2021.1.0, which we've just released. You can find the changelog here: https://github.com/microsoft/pylance-release/blob/main/CHANGELOG.md#202110-6-january-2021