Skip to content

Commit

Permalink
fix lint: mypy & black (#1070)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jasha10 committed Apr 14, 2023
1 parent 5b6257b commit 97c0a47
Show file tree
Hide file tree
Showing 12 changed files with 6 additions and 17 deletions.
4 changes: 3 additions & 1 deletion omegaconf/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,9 @@ def is_dataclass(obj: Any) -> bool:

if dataclasses is None or isinstance(obj, Node):
return False
return dataclasses.is_dataclass(obj)
is_dataclass = dataclasses.is_dataclass(obj)
assert isinstance(is_dataclass, bool)
return is_dataclass


def is_attr_class(obj: Any) -> bool:
Expand Down
1 change: 0 additions & 1 deletion omegaconf/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@

@dataclass
class Metadata:

ref_type: Union[Type[Any], Any]

object_type: Union[Type[Any], Any]
Expand Down
3 changes: 0 additions & 3 deletions omegaconf/dictconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@


class DictConfig(BaseContainer, MutableMapping[Any, Any]):

_metadata: ContainerMetadata
_content: Union[Dict[DictKeyType, Node], None, str]

Expand Down Expand Up @@ -240,7 +239,6 @@ def _validate_merge(self, value: Any) -> None:

def _validate_non_optional(self, key: Optional[DictKeyType], value: Any) -> None:
if _is_none(value, resolve=True, throw_on_resolution_failure=False):

if key is not None:
child = self._get_node(key)
if child is not None:
Expand Down Expand Up @@ -696,7 +694,6 @@ def _set_value_impl(

@staticmethod
def _dict_conf_eq(d1: "DictConfig", d2: "DictConfig") -> bool:

d1_none = d1.__dict__["_content"] is None
d2_none = d2.__dict__["_content"] is None
if d1_none and d2_none:
Expand Down
1 change: 0 additions & 1 deletion omegaconf/grammar_visitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ def visitInterpolationNode(
def visitInterpolationResolver(
self, ctx: OmegaConfGrammarParser.InterpolationResolverContext
) -> Any:

# INTER_OPEN resolverName COLON sequence? BRACE_CLOSE
assert 4 <= ctx.getChildCount() <= 5

Expand Down
2 changes: 0 additions & 2 deletions omegaconf/listconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@


class ListConfig(BaseContainer, MutableSequence[Any]):

_content: Union[List[Node], None, str]

def __init__(
Expand Down Expand Up @@ -541,7 +540,6 @@ def __init__(self, lst: Any, resolve: bool) -> None:
self.ValueNode = ValueNode

def __next__(self) -> Any:

x = next(self.iterator)
if self.resolve:
x = x._dereference_node()
Expand Down
1 change: 0 additions & 1 deletion tests/interpolation/built_in_resolvers/test_oc_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ def test_get_and_validate_dict_input(
def test_dict_values(
cfg: Any, key: Any, expected_val: Any, expected_content: Any
) -> None:

cfg = OmegaConf.create(cfg)
val = cfg[key]
assert val == expected_val
Expand Down
1 change: 0 additions & 1 deletion tests/structured_conf/data/attr_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -838,6 +838,5 @@ class HasIgnoreMetadataRequired:

@attr.s(auto_attribs=True)
class HasIgnoreMetadataWithDefault:

ignore: int = attr.field(default=1, metadata={"omegaconf_ignore": True})
no_ignore: int = attr.field(default=2, metadata={"omegaconf_ignore": False})
2 changes: 0 additions & 2 deletions tests/structured_conf/test_structured_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,6 @@ def test_promote_api(self, module: Any) -> None:
assert conf == OmegaConf.create(module.AnyTypeConfig)

def test_promote_to_class(self, module: Any) -> None:

conf = OmegaConf.create(module.AnyTypeConfig)
assert OmegaConf.get_type(conf) == module.AnyTypeConfig

Expand All @@ -866,7 +865,6 @@ def test_promote_to_class(self, module: Any) -> None:
assert OmegaConf.is_missing(conf, "mandatory_missing")

def test_promote_to_object(self, module: Any) -> None:

conf = OmegaConf.create(module.AnyTypeConfig)
assert OmegaConf.get_type(conf) == module.AnyTypeConfig

Expand Down
1 change: 0 additions & 1 deletion tests/test_basic_ops_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -919,7 +919,6 @@ def test_struct_mode_missing_key_setitem() -> None:


def test_get_type() -> None:

cfg = OmegaConf.structured(User)
assert OmegaConf.get_type(cfg) == User

Expand Down
1 change: 0 additions & 1 deletion tests/test_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,6 @@ def test_accepts_mandatory_missing(
def test_legal_assignment(
type_: type, values: Any, success_map: Dict[Any, Dict[str, Any]]
) -> None:

if not isinstance(values, (list, tuple)):
values = [values]

Expand Down
4 changes: 2 additions & 2 deletions tests/test_unions.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
)
class TestUnionNode:
def test_creation(self, input_: Any, union_args: Any) -> None:
ref_type = Union[union_args] # type: ignore
ref_type = Union[union_args]
legal = type(input_) in union_args
if legal:
node = UnionNode(input_, ref_type)
Expand All @@ -47,7 +47,7 @@ def test_creation(self, input_: Any, union_args: Any) -> None:
UnionNode(input_, ref_type)

def test_set_value(self, input_: Any, union_args: Any) -> None:
ref_type = Union[union_args] # type: ignore
ref_type = Union[union_args]
legal = type(input_) in union_args
node = UnionNode(None, ref_type)
if legal:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ def test_get_class() -> None:
def test_get_key_value_types(
key_type: Any, expected_key_type: Any, value_type: Any, expected_value_type: Any
) -> None:
dt = Dict[key_type, value_type] # type:ignore
dt = Dict[key_type, value_type]
assert _utils.get_dict_key_value_types(dt) == (
expected_key_type,
expected_value_type,
Expand Down

0 comments on commit 97c0a47

Please sign in to comment.