Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove warning for missing networks #288

Open
wants to merge 5 commits into
base: 2.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 16 additions & 30 deletions eth_utils/curried/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,22 +113,19 @@
@overload
def apply_formatter_if(
condition: Callable[..., bool]
) -> Callable[[Callable[..., TReturn]], Callable[[TValue], Union[TReturn, TValue]]]:
...
) -> Callable[[Callable[..., TReturn]], Callable[[TValue], Union[TReturn, TValue]]]: ...


@overload
def apply_formatter_if(
condition: Callable[..., bool], formatter: Callable[..., TReturn]
) -> Callable[[TValue], Union[TReturn, TValue]]:
...
) -> Callable[[TValue], Union[TReturn, TValue]]: ...


@overload
def apply_formatter_if(
condition: Callable[..., bool], formatter: Callable[..., TReturn], value: TValue
) -> Union[TReturn, TValue]:
...
) -> Union[TReturn, TValue]: ...


# This is just a stub to appease mypy, it gets overwritten later
Expand All @@ -141,17 +138,15 @@ def apply_formatter_if(
Callable[[TValue], Union[TReturn, TValue]],
TReturn,
TValue,
]:
...
]: ...


@overload
def apply_one_of_formatters(
formatter_condition_pairs: Sequence[
Tuple[Callable[..., bool], Callable[..., TReturn]]
]
) -> Callable[[TValue], TReturn]:
...
) -> Callable[[TValue], TReturn]: ...


@overload
Expand All @@ -160,8 +155,7 @@ def apply_one_of_formatters(
Tuple[Callable[..., bool], Callable[..., TReturn]]
],
value: TValue,
) -> TReturn:
...
) -> TReturn: ...


# This is just a stub to appease mypy, it gets overwritten later
Expand All @@ -170,70 +164,62 @@ def apply_one_of_formatters(
Tuple[Callable[..., bool], Callable[..., TReturn]]
],
value: TValue = None,
) -> TReturn:
...
) -> TReturn: ...


@overload
def hexstr_if_str(
to_type: Callable[..., TReturn]
) -> Callable[[Union[bytes, int, str]], TReturn]:
...
) -> Callable[[Union[bytes, int, str]], TReturn]: ...


@overload
def hexstr_if_str(
to_type: Callable[..., TReturn], to_format: Union[bytes, int, str]
) -> TReturn:
...
) -> TReturn: ...


# This is just a stub to appease mypy, it gets overwritten later
def hexstr_if_str(
to_type: Callable[..., TReturn], to_format: Union[bytes, int, str] = None
) -> TReturn:
...
) -> TReturn: ...


@overload
def text_if_str(
to_type: Callable[..., TReturn]
) -> Callable[[Union[bytes, int, str]], TReturn]:
...
) -> Callable[[Union[bytes, int, str]], TReturn]: ...


@overload
def text_if_str(
to_type: Callable[..., TReturn], text_or_primitive: Union[bytes, int, str]
) -> TReturn:
...
) -> TReturn: ...


# This is just a stub to appease mypy, it gets overwritten later
def text_if_str(
to_type: Callable[..., TReturn], text_or_primitive: Union[bytes, int, str] = None
) -> TReturn:
...
) -> TReturn: ...


@overload
def apply_formatters_to_dict(
formatters: Dict[Any, Any]
) -> Callable[[Dict[Any, Any]], TReturn]:
...
) -> Callable[[Dict[Any, Any]], TReturn]: ...


@overload
def apply_formatters_to_dict(
formatters: Dict[Any, Any], value: Dict[Any, Any]
) -> TReturn:
) -> TReturn: # type: ignore
...


# This is just a stub to appease mypy, it gets overwritten later
def apply_formatters_to_dict(
formatters: Dict[Any, Any], value: Optional[Dict[Any, Any]] = None
) -> TReturn:
) -> TReturn: # type: ignore
...


Expand Down
2 changes: 1 addition & 1 deletion eth_utils/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def return_arg_type(at_position: int) -> Callable[..., Callable[..., T]]:

def decorator(to_wrap: Callable[..., Any]) -> Callable[..., T]:
@functools.wraps(to_wrap)
def wrapper(*args: Any, **kwargs: Any) -> T:
def wrapper(*args: Any, **kwargs: Any) -> T: # type: ignore
result = to_wrap(*args, **kwargs)
ReturnType = type(args[at_position])
return ReturnType(result) # type: ignore
Expand Down
10 changes: 3 additions & 7 deletions eth_utils/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import json
import os
from typing import List
import warnings

from eth_typing import ChainId

Expand Down Expand Up @@ -40,12 +39,9 @@ def initialize_network_objects() -> List[Network]:
)
networks_obj.append(network)
except ValueError:
# Entry does not have a valid ChainId constant in eth-typing
warnings.warn(
f"Network {entry['chainId']} with name '{entry['name']}' does not have "
f"a valid ChainId. eth-typing should be updated with the latest "
f"networks."
)
# Chain does not have a valid ChainId, network files in eth-utils and
# eth-typing should to be updated. Run `python update_networks.py` in the
# project root.
pass
return networks_obj

Expand Down
6 changes: 2 additions & 4 deletions eth_utils/numeric.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@

class Comparable(ABC):
@abstractmethod
def __lt__(self, other: Any) -> bool:
...
def __lt__(self, other: Any) -> bool: ...

@abstractmethod
def __gt__(self, other: Any) -> bool:
...
def __gt__(self, other: Any) -> bool: ...


TComparable = Union[Comparable, numbers.Real, int, float, decimal.Decimal]
Expand Down
1 change: 1 addition & 0 deletions newsfragments/288.internal.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Bump ``mypy`` to ``v0.991`` and fix lint errors
1 change: 1 addition & 0 deletions newsfragments/288.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
No warning for outdated networks.
9 changes: 3 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from setuptools import (
setup,
find_packages,
)
from setuptools import find_packages, setup

extras_require = {
"test": [
"hypothesis>=4.43.0",
"pytest>=7.0.0",
"pytest-xdist>=2.4.0",
"types-setuptools",
"mypy==0.971", # mypy does not follow semver, leave it pinned.
"mypy==0.991", # mypy does not follow semver, leave it pinned.
],
"lint": [
"flake8==3.8.3", # flake8 claims semver but adds new warnings at minor releases, leave it pinned.
"isort>=5.11.0",
"mypy==0.971", # mypy does not follow semver, leave it pinned.
"mypy==0.991", # mypy does not follow semver, leave it pinned.
"pydocstyle>=5.0.0",
"black>=23",
"types-setuptools",
Expand Down
2 changes: 1 addition & 1 deletion tests/functional-utils/test_type_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def check_mypy_run(
cmd_line: List[str],
expected_out: str,
expected_err: str = "",
expected_returncode: int = 1,
expected_returncode: int = 0,
) -> None:
"""Helper to run mypy and check the output."""
out, err, returncode = api.run(cmd_line)
Expand Down
3 changes: 1 addition & 2 deletions tests/logging-utils/test_compat_with_abc_ABC.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@

class HasLoggerCompatWithABC(metaclass=HasLoggerMeta.meta_compat(ABCMeta)):
@abstractmethod
def something(self):
...
def something(self): ...


def test_has_logger_compat_with_abc_ABC():
Expand Down