Address mypy's typing concerns

This commit is contained in:
Marcin Kulik
2023-03-02 11:44:20 +01:00
parent 35fea017aa
commit f7b15c73c5

View File

@@ -13,13 +13,18 @@ from .commands.upload import UploadCommand
def valid_encoding() -> bool: def valid_encoding() -> bool:
def _locales() -> str: def _locales() -> Optional[str]:
try: try:
return locale.nl_langinfo(locale.CODESET) return locale.nl_langinfo(locale.CODESET)
except AttributeError: except AttributeError:
return locale.getlocale()[-1] return locale.getlocale()[-1]
return _locales().upper() in ("US-ASCII", "UTF-8", "UTF8") loc = _locales()
if loc is None:
return False
else:
return loc.upper() in ("US-ASCII", "UTF-8", "UTF8")
def positive_int(value: str) -> int: def positive_int(value: str) -> int: