From 0cf0bed1f9ec45fc5d4a9379e88c5ed2f0386b48 Mon Sep 17 00:00:00 2001 From: Jasha10 <8935917+Jasha10@users.noreply.github.com> Date: Fri, 30 Sep 2022 13:04:09 -0500 Subject: [PATCH] mypy: update python_version and type: ignore comments (#1016) 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. --- benchmark/benchmark.py | 21 +++++++++---------- omegaconf/_utils.py | 2 +- setup.cfg | 2 +- .../dataclass_postponed_annotations.py | 2 +- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/benchmark/benchmark.py b/benchmark/benchmark.py index 04e005613..478cccf4a 100644 --- a/benchmark/benchmark.py +++ b/benchmark/benchmark.py @@ -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 @@ -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: @@ -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: @@ -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: diff --git a/omegaconf/_utils.py b/omegaconf/_utils.py index 6d3e38d60..ffec246a3 100644 --- a/omegaconf/_utils.py +++ b/omegaconf/_utils.py @@ -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) diff --git a/setup.cfg b/setup.cfg index 85e985dc1..f1a1fff8b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -2,7 +2,7 @@ test=pytest [mypy] -python_version = 3.6 +python_version = 3.7 mypy_path=.stubs exclude = build/ diff --git a/tests/examples/dataclass_postponed_annotations.py b/tests/examples/dataclass_postponed_annotations.py index 5fe32defc..ada14efd7 100644 --- a/tests/examples/dataclass_postponed_annotations.py +++ b/tests/examples/dataclass_postponed_annotations.py @@ -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