A few linting fixes

Add some Python 3.8 type: ignores; all are already fixed in the next
mypy release, so can be removed once we upgrade.

Also move some flake8 ignores which seem to have changed places.
This commit is contained in:
Ran Benita 2019-11-15 15:16:40 +02:00
parent c49c61fdaf
commit f760356578
5 changed files with 13 additions and 9 deletions

View File

@ -60,7 +60,7 @@ class Source:
raise NotImplementedError()
@overload # noqa: F811
def __getitem__(self, key: slice) -> "Source":
def __getitem__(self, key: slice) -> "Source": # noqa: F811
raise NotImplementedError()
def __getitem__(self, key: Union[int, slice]) -> Union[str, "Source"]: # noqa: F811

View File

@ -1074,13 +1074,14 @@ def try_makedirs(cache_dir) -> bool:
def get_cache_dir(file_path: Path) -> Path:
"""Returns the cache directory to write .pyc files for the given .py file path"""
if sys.version_info >= (3, 8) and sys.pycache_prefix:
# Type ignored until added in next mypy release.
if sys.version_info >= (3, 8) and sys.pycache_prefix: # type: ignore
# given:
# prefix = '/tmp/pycs'
# path = '/home/user/proj/test_app.py'
# we want:
# '/tmp/pycs/home/user/proj'
return Path(sys.pycache_prefix) / Path(*file_path.parts[1:-1])
return Path(sys.pycache_prefix) / Path(*file_path.parts[1:-1]) # type: ignore
else:
# classic pycache directory
return file_path.parent / "__pycache__"

View File

@ -40,7 +40,8 @@ MODULE_NOT_FOUND_ERROR = (
if sys.version_info >= (3, 8):
from importlib import metadata as importlib_metadata # noqa: F401
# Type ignored until next mypy release.
from importlib import metadata as importlib_metadata # type: ignore
else:
import importlib_metadata # noqa: F401
@ -407,7 +408,9 @@ else:
raise NotImplementedError()
@overload # noqa: F811
def __get__(self, instance: _S, owner: Optional["Type[_S]"] = ...) -> _T:
def __get__( # noqa: F811
self, instance: _S, owner: Optional["Type[_S]"] = ...
) -> _T:
raise NotImplementedError()
def __get__(self, instance, owner=None): # noqa: F811

View File

@ -552,7 +552,7 @@ def raises(
@overload # noqa: F811
def raises(
def raises( # noqa: F811
expected_exception: Union["Type[_E]", Tuple["Type[_E]", ...]],
func: Callable,
*args: Any,

View File

@ -60,18 +60,18 @@ def warns(
*,
match: "Optional[Union[str, Pattern]]" = ...
) -> "WarningsChecker":
... # pragma: no cover
raise NotImplementedError()
@overload # noqa: F811
def warns(
def warns( # noqa: F811
expected_warning: Union["Type[Warning]", Tuple["Type[Warning]", ...]],
func: Callable,
*args: Any,
match: Optional[Union[str, "Pattern"]] = ...,
**kwargs: Any
) -> Union[Any]:
... # pragma: no cover
raise NotImplementedError()
def warns( # noqa: F811