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

Bump mypy from 0.982 to 1.0.0 in /requirements #1516

Merged
merged 31 commits into from
Feb 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
2857423
Bump mypy from 0.982 to 1.0.0 in /requirements
dependabot[bot] Feb 17, 2023
99ff2b8
mypy: Fix PEP 484 issues
stancld Feb 17, 2023
41d0846
mypy: Drop unused ignore comments
stancld Feb 17, 2023
0586844
mypy: Function "Callable[[], bool]" could always be true in boolean c…
stancld Feb 17, 2023
dbfd20b
Merge branch 'master' into dependabot-pip-requirements-mypy-1.0.0
Borda Feb 18, 2023
f494f1a
Merge branch 'master' into dependabot-pip-requirements-mypy-1.0.0
mergify[bot] Feb 20, 2023
d16c0f1
Merge branch 'master' into dependabot-pip-requirements-mypy-1.0.0
mergify[bot] Feb 20, 2023
8e17d5c
Merge branch 'master' into dependabot-pip-requirements-mypy-1.0.0
mergify[bot] Feb 20, 2023
75a0090
Merge branch 'master' into dependabot-pip-requirements-mypy-1.0.0
mergify[bot] Feb 20, 2023
f1dd415
Merge branch 'master' into dependabot-pip-requirements-mypy-1.0.0
mergify[bot] Feb 20, 2023
608d9c0
Merge branch 'master' into dependabot-pip-requirements-mypy-1.0.0
mergify[bot] Feb 20, 2023
f8f62e3
Merge branch 'master' into dependabot-pip-requirements-mypy-1.0.0
mergify[bot] Feb 20, 2023
7a0f2cc
Merge branch 'master' into dependabot-pip-requirements-mypy-1.0.0
mergify[bot] Feb 20, 2023
b6a9d0b
Merge branch 'master' into dependabot-pip-requirements-mypy-1.0.0
mergify[bot] Feb 21, 2023
d709091
Merge branch 'master' into dependabot-pip-requirements-mypy-1.0.0
mergify[bot] Feb 21, 2023
b0f8f9c
Merge branch 'master' into dependabot-pip-requirements-mypy-1.0.0
mergify[bot] Feb 21, 2023
ba3b3d8
Merge branch 'master' into dependabot-pip-requirements-mypy-1.0.0
mergify[bot] Feb 21, 2023
d670138
Merge branch 'master' into dependabot-pip-requirements-mypy-1.0.0
mergify[bot] Feb 21, 2023
ad7f281
Merge branch 'master' into dependabot-pip-requirements-mypy-1.0.0
Borda Feb 22, 2023
f5b4d44
Merge branch 'master' into dependabot-pip-requirements-mypy-1.0.0
mergify[bot] Feb 22, 2023
99583c7
ci: rename testing-guardian
Borda Feb 22, 2023
5775125
Merge branch 'master' into dependabot-pip-requirements-mypy-1.0.0
mergify[bot] Feb 22, 2023
39100f5
Merge branch 'master' into dependabot-pip-requirements-mypy-1.0.0
mergify[bot] Feb 22, 2023
a8451b3
Merge branch 'master' into dependabot-pip-requirements-mypy-1.0.0
mergify[bot] Feb 22, 2023
93777ae
Merge branch 'master' into dependabot-pip-requirements-mypy-1.0.0
mergify[bot] Feb 22, 2023
96c78af
Apply suggestions from code review
Borda Feb 22, 2023
07acb95
ignore
Borda Feb 22, 2023
82ec97b
Merge branch 'master' into dependabot-pip-requirements-mypy-1.0.0
Borda Feb 22, 2023
e370475
Merge branch 'master' into dependabot-pip-requirements-mypy-1.0.0
Borda Feb 22, 2023
136ae36
optional
Borda Feb 22, 2023
fe027f8
Merge branch 'dependabot-pip-requirements-mypy-1.0.0' of https://gith…
Borda Feb 22, 2023
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
3 changes: 2 additions & 1 deletion requirements/typing.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
mypy==0.982
mypy==1.0.0

types-PyYAML
types-emoji
types-protobuf
Expand Down
4 changes: 2 additions & 2 deletions src/torchmetrics/functional/regression/mae.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ def _mean_absolute_error_update(preds: Tensor, target: Tensor) -> Tuple[Tensor,
target: Ground truth tensor
"""
_check_same_shape(preds, target)
preds = preds if preds.is_floating_point else preds.float()
target = target if target.is_floating_point else target.float()
preds = preds if preds.is_floating_point else preds.float() # type: ignore[truthy-function] # todo
target = target if target.is_floating_point else target.float() # type: ignore[truthy-function] # todo
sum_abs_error = torch.sum(torch.abs(preds - target))
n_obs = target.numel()
return sum_abs_error, n_obs
Expand Down
4 changes: 2 additions & 2 deletions src/torchmetrics/functional/text/bert.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def _get_embeddings_and_idf_scale(
all_layers: bool = False,
idf: bool = False,
verbose: bool = False,
user_forward_fn: Callable[[Module, Dict[str, Tensor]], Tensor] = None,
user_forward_fn: Optional[Callable[[Module, Dict[str, Tensor]], Tensor]] = None,
) -> Tuple[Tensor, Tensor]:
"""Calculate sentence embeddings and the inverse-document-frequency scaling factor.

Expand Down Expand Up @@ -249,7 +249,7 @@ def bert_score(
all_layers: bool = False,
model: Optional[Module] = None,
user_tokenizer: Any = None,
user_forward_fn: Callable[[Module, Dict[str, Tensor]], Tensor] = None,
user_forward_fn: Optional[Callable[[Module, Dict[str, Tensor]], Tensor]] = None,
verbose: bool = False,
idf: bool = False,
device: Optional[Union[str, torch.device]] = None,
Expand Down
12 changes: 6 additions & 6 deletions src/torchmetrics/functional/text/rouge.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ def find_union(lcs_tables: Sequence[Sequence[int]]) -> Sequence[int]:
def _normalize_and_tokenize_text(
text: str,
stemmer: Optional[Any] = None,
normalizer: Callable[[str], str] = None,
tokenizer: Callable[[str], Sequence[str]] = None,
normalizer: Optional[Callable[[str], str]] = None,
tokenizer: Optional[Callable[[str], Sequence[str]]] = None,
) -> Sequence[str]:
"""Rouge score should be calculated only over lowercased words and digits. Optionally, Porter stemmer can be
used to strip word suffixes to improve matching. The text normalization follows the implemantion from `Rouge
Expand Down Expand Up @@ -282,8 +282,8 @@ def _rouge_score_update(
rouge_keys_values: List[Union[int, str]],
accumulate: str,
stemmer: Optional[Any] = None,
normalizer: Callable[[str], str] = None,
tokenizer: Callable[[str], Sequence[str]] = None,
normalizer: Optional[Callable[[str], str]] = None,
tokenizer: Optional[Callable[[str], Sequence[str]]] = None,
) -> Dict[Union[int, str], List[Dict[str, Tensor]]]:
"""Update the rouge score with the current set of predicted and target sentences.

Expand Down Expand Up @@ -412,8 +412,8 @@ def rouge_score(
target: Union[str, Sequence[str], Sequence[Sequence[str]]],
accumulate: Literal["avg", "best"] = "best",
use_stemmer: bool = False,
normalizer: Callable[[str], str] = None,
tokenizer: Callable[[str], Sequence[str]] = None,
normalizer: Optional[Callable[[str], str]] = None,
tokenizer: Optional[Callable[[str], Sequence[str]]] = None,
rouge_keys: Union[str, Tuple[str, ...]] = ("rouge1", "rouge2", "rougeL", "rougeLsum"),
) -> Dict[str, Tensor]:
"""Calculate `Calculate Rouge Score`_ , used for automatic summarization.
Expand Down
2 changes: 1 addition & 1 deletion src/torchmetrics/metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ def persistent(self, mode: bool = False) -> None:

def state_dict( # type: ignore[override] # todo
self,
destination: Dict[str, Any] = None,
destination: Optional[Dict[str, Any]] = None,
prefix: str = "",
keep_vars: bool = False,
) -> Dict[str, Any]:
Expand Down
2 changes: 1 addition & 1 deletion src/torchmetrics/text/bert.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def __init__(
all_layers: bool = False,
model: Optional[Module] = None,
user_tokenizer: Optional[Any] = None,
user_forward_fn: Callable[[Module, Dict[str, Tensor]], Tensor] = None,
user_forward_fn: Optional[Callable[[Module, Dict[str, Tensor]], Tensor]] = None,
verbose: bool = False,
idf: bool = False,
device: Optional[Union[str, torch.device]] = None,
Expand Down
6 changes: 3 additions & 3 deletions src/torchmetrics/text/rouge.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import Any, Callable, Dict, List, Sequence, Tuple, Union
from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union

from torch import Tensor
from typing_extensions import Literal
Expand Down Expand Up @@ -97,8 +97,8 @@ class ROUGEScore(Metric):
def __init__(
self,
use_stemmer: bool = False,
normalizer: Callable[[str], str] = None,
tokenizer: Callable[[str], Sequence[str]] = None,
normalizer: Optional[Callable[[str], str]] = None,
tokenizer: Optional[Callable[[str], Sequence[str]]] = None,
accumulate: Literal["avg", "best"] = "best",
rouge_keys: Union[str, Tuple[str, ...]] = ("rouge1", "rouge2", "rougeL", "rougeLsum"),
**kwargs: Any,
Expand Down