Make version hack more reliable

This commit is contained in:
Tzu-ping Chung 2022-04-08 22:15:58 +08:00
parent f9e554c999
commit ee81f71d7c
1 changed files with 2 additions and 2 deletions

View File

@ -1,5 +1,5 @@
import importlib.metadata
from typing import Optional, Protocol
from typing import Any, Optional, Protocol, cast
class BasePath(Protocol):
@ -38,4 +38,4 @@ def get_dist_name(dist: importlib.metadata.Distribution) -> str:
The ``name`` attribute is only available in Python 3.10 or later. We are
targeting exactly that, but Mypy does not know this.
"""
return dist.name # type: ignore[attr-defined]
return cast(Any, dist).name