The source project of this merge request has been removed.
Mark name and value functions in typing as properties to correctly detect...
This might not be required at at all and might be a random glitch? Further investigation required.
This issue is still valid, although it happens only "sometimes" and "somewhere".
This merge request fixes this issue by marking ENUM_MEMBER.name and ENUM_MEMBER.value as @property in the typing fastenum.pyi file.
In this example, where squid.entities.AlternativeIdDomains is class AlternativeIdDomains(fastenum.Enum) from external library and fastenum isn't used in the project directly.
An error is thrown when checking with MyPY: file.py:4: error: Invalid index type "Callable[[], Any]" for "Mapping[str, Any]"; expected type "str" [index].
main.py
from typing import Mapping, Any
import octopus
def has_yahoo_id(data: Mapping[str, Any]) -> bool:
return data[octopus.OutsideId.YAHOO_TICKER.value] is not None
has_yahoo_id(
{
octopus.OutsideId.YAHOO_TICKER.value: 'AAPL',
}
)
mypy.ini
[mypy]
plugins = fastenum.mypy_plugin:plugin
pyproject.toml
[tool.poetry]
name = "example-project"
version = "0.1.0"
[tool.poetry.dependencies]
python = ">=3.10,<3.13"
octopus = "^1.2.3"
[[tool.poetry.source]]
name = "private-pypi"
url = "..."
priority = "primary"
[[tool.poetry.source]]
name = "PyPI"
priority = "primary"
[tool.poetry.group.dev.dependencies]
ql-cq = "^1.7.0"
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
Edited by Antonín Kříž