Skip to content

Commit

Permalink
mypy: update python_version and type: ignore comments (omry#1016)
Browse files Browse the repository at this point in the history
Mypy no longer officially supports python3.6.
Updating the `python_version` setting in the mypy config
avoids some errors that were only showing up when mypy was
installed with python3.6.
  • Loading branch information
Jasha10 authored Sep 30, 2022
1 parent bc89a7f commit 0cf0bed
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
21 changes: 10 additions & 11 deletions benchmark/benchmark.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import copy
from typing import Any, Dict, List

from pytest import lazy_fixture # type: ignore
from pytest import fixture, mark, param
from pytest import fixture, lazy_fixture, mark, param

from omegaconf import OmegaConf
from omegaconf._utils import ValueKind, _is_missing_literal, get_value_kind
Expand Down Expand Up @@ -75,11 +74,11 @@ def small_listconfig(small_list: Any) -> Any:
@mark.parametrize(
"data",
[
lazy_fixture("small_dict"),
lazy_fixture("large_dict"),
lazy_fixture("small_dict_config"),
lazy_fixture("large_dict_config"),
lazy_fixture("dict_config_with_list_leaf"),
lazy_fixture("small_dict"), # type: ignore
lazy_fixture("large_dict"), # type: ignore
lazy_fixture("small_dict_config"), # type: ignore
lazy_fixture("large_dict_config"), # type: ignore
lazy_fixture("dict_config_with_list_leaf"), # type: ignore
],
)
def test_omegaconf_create(data: Any, benchmark: Any) -> None:
Expand All @@ -100,8 +99,8 @@ def test_omegaconf_merge(merge_function: Any, merge_data: Any, benchmark: Any) -
@mark.parametrize(
"lst",
[
lazy_fixture("small_list"),
lazy_fixture("small_listconfig"),
lazy_fixture("small_list"), # type: ignore
lazy_fixture("small_listconfig"), # type: ignore
],
)
def test_list_in(lst: List[Any], benchmark: Any) -> None:
Expand All @@ -111,8 +110,8 @@ def test_list_in(lst: List[Any], benchmark: Any) -> None:
@mark.parametrize(
"lst",
[
lazy_fixture("small_list"),
lazy_fixture("small_listconfig"),
lazy_fixture("small_list"), # type: ignore
lazy_fixture("small_listconfig"), # type: ignore
],
)
def test_list_iter(lst: List[Any], benchmark: Any) -> None:
Expand Down
2 changes: 1 addition & 1 deletion omegaconf/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ def get_dataclass_data(
is_optional, type_ = _resolve_optional(resolved_hints[field.name])
type_ = _resolve_forward(type_, obj.__module__)
has_default = field.default != dataclasses.MISSING
has_default_factory = field.default_factory != dataclasses.MISSING # type: ignore
has_default_factory = field.default_factory != dataclasses.MISSING

if not is_type:
value = getattr(obj, name)
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
test=pytest

[mypy]
python_version = 3.6
python_version = 3.7
mypy_path=.stubs
exclude = build/

Expand Down
2 changes: 1 addition & 1 deletion tests/examples/dataclass_postponed_annotations.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `from __future__` has to be the very first thing in a module
# otherwise a syntax error is raised
from __future__ import annotations # type: ignore # noqa # Python 3.6 linters complain
from __future__ import annotations # noqa # Python 3.6 linters complain

from dataclasses import dataclass, fields
from enum import Enum
Expand Down

0 comments on commit 0cf0bed

Please sign in to comment.