Skip to content

Commit

Permalink
build(deps-dev): bump mypy from 1.6.1 to 1.7.0 (#10088)
Browse files Browse the repository at this point in the history
* build(deps-dev): bump mypy from 1.6.1 to 1.7.0

Bumps [mypy](https://github.com/python/mypy) from 1.6.1 to 1.7.0.
- [Changelog](https://github.com/python/mypy/blob/master/CHANGELOG.md)
- [Commits](python/mypy@v1.6.1...v1.7.0)

---
updated-dependencies:
- dependency-name: mypy
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

* fix misc mypy errors

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Ruslan Kuprieiev <[email protected]>
  • Loading branch information
dependabot[bot] and efiop authored Nov 13, 2023
1 parent b2fc194 commit 8d23a5e
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 59 deletions.
3 changes: 2 additions & 1 deletion dvc/_debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ def show_stack():
signal.signal(signal.SIGQUIT, _sigshow)

try:
signal.signal(signal.SIGINFO, _sigshow) # only available on macOS
# only available on macOS
signal.signal(signal.SIGINFO, _sigshow) # type: ignore[attr-defined]
except AttributeError:
pass
yield
Expand Down
2 changes: 1 addition & 1 deletion dvc/annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def to_dict(self) -> Dict[str, str]:
Annotation.PARAM_LABELS: [str],
Annotation.PARAM_META: object,
}
ARTIFACT_SCHEMA = {
ARTIFACT_SCHEMA: Dict[Any, Any] = {
Required(Artifact.PARAM_PATH): str,
**ANNOTATION_SCHEMA, # type: ignore[arg-type]
}
10 changes: 5 additions & 5 deletions dvc/dependency/repo.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from copy import deepcopy
from typing import TYPE_CHECKING, Dict, Optional, Union
from typing import TYPE_CHECKING, Any, Dict, Optional, Union

from voluptuous import Any, Required
import voluptuous as vol

from dvc.utils import as_posix

Expand All @@ -22,11 +22,11 @@ class RepoDependency(Dependency):

REPO_SCHEMA = {
PARAM_REPO: {
Required(PARAM_URL): str,
vol.Required(PARAM_URL): str,
PARAM_REV: str,
PARAM_REV_LOCK: str,
PARAM_CONFIG: Any(str, dict),
PARAM_REMOTE: Any(str, dict),
PARAM_CONFIG: vol.Any(str, dict),
PARAM_REMOTE: vol.Any(str, dict),
}
}

Expand Down
26 changes: 13 additions & 13 deletions dvc/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
from collections import defaultdict
from contextlib import suppress
from operator import itemgetter
from typing import TYPE_CHECKING, Dict, List, Optional, Set, Tuple, Type, Union
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Set, Tuple, Type, Union
from urllib.parse import urlparse

import voluptuous as vol
from funcy import collecting, first, project
from voluptuous import All, And, Any, Coerce, Length, Lower, Required, SetTo

from dvc import prompt
from dvc.exceptions import (
Expand Down Expand Up @@ -50,16 +50,16 @@
logger = logger.getChild(__name__)


CHECKSUM_SCHEMA = Any(
CHECKSUM_SCHEMA = vol.Any(
None,
And(str, Length(max=0), SetTo(None)),
And(Any(str, And(int, Coerce(str))), Length(min=3), Lower),
vol.And(str, vol.Length(max=0), vol.SetTo(None)),
vol.And(vol.Any(str, vol.And(int, vol.Coerce(str))), vol.Length(min=3), vol.Lower),
)

CASE_SENSITIVE_CHECKSUM_SCHEMA = Any(
CASE_SENSITIVE_CHECKSUM_SCHEMA = vol.Any(
None,
And(str, Length(max=0), SetTo(None)),
And(Any(str, And(int, Coerce(str))), Length(min=3)),
vol.And(str, vol.Length(max=0), vol.SetTo(None)),
vol.And(vol.Any(str, vol.And(int, vol.Coerce(str))), vol.Length(min=3)),
)

# NOTE: currently there are only 3 possible checksum names:
Expand Down Expand Up @@ -1518,21 +1518,21 @@ def _merge_dir_version_meta(self, other: "Output"):
Meta.PARAM_VERSION_ID: str,
}

CLOUD_SCHEMA = All({str: {**META_SCHEMA, **CHECKSUMS_SCHEMA}}, Length(max=1))
CLOUD_SCHEMA = vol.All({str: {**META_SCHEMA, **CHECKSUMS_SCHEMA}}, vol.Length(max=1))

ARTIFACT_SCHEMA = {
ARTIFACT_SCHEMA: Dict[Any, Any] = {
**CHECKSUMS_SCHEMA,
**META_SCHEMA,
Required(Output.PARAM_PATH): str,
vol.Required(Output.PARAM_PATH): str,
Output.PARAM_PERSIST: bool,
Output.PARAM_CLOUD: CLOUD_SCHEMA,
Output.PARAM_HASH: str,
}

DIR_FILES_SCHEMA: Dict[str, Any] = {
DIR_FILES_SCHEMA: Dict[Any, Any] = {
**CHECKSUMS_SCHEMA,
**META_SCHEMA,
Required(Tree.PARAM_RELPATH): str,
vol.Required(Tree.PARAM_RELPATH): str,
Output.PARAM_CLOUD: CLOUD_SCHEMA,
}

Expand Down
8 changes: 4 additions & 4 deletions dvc/render/converter/vega.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,9 @@ def flat_datapoints(self, revision): # noqa: C901, PLR0912

all_datapoints = []
if ys:
all_y_files, all_y_fields = list(zip(*ys))
all_y_fields = set(all_y_fields)
all_y_files = set(all_y_files)
_all_y_files, _all_y_fields = list(zip(*ys))
all_y_fields = set(_all_y_fields)
all_y_files = set(_all_y_files)
else:
all_y_files = set()
all_y_fields = set()
Expand All @@ -233,7 +233,7 @@ def flat_datapoints(self, revision): # noqa: C901, PLR0912

# get common prefix to drop from file names
if len(all_y_files) > 1:
common_prefix_len = len(os.path.commonpath(all_y_files))
common_prefix_len = len(os.path.commonpath(list(all_y_files)))
else:
common_prefix_len = 0

Expand Down
69 changes: 35 additions & 34 deletions dvc/schema.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from collections.abc import Mapping
from typing import Any, Dict

from voluptuous import Any, Equal, Optional, Required, Schema
import voluptuous as vol

from dvc import dependency, output
from dvc.annotations import ANNOTATION_SCHEMA, ARTIFACT_SCHEMA
Expand All @@ -17,34 +18,34 @@
STAGES = "stages"
SINGLE_STAGE_SCHEMA = {
StageParams.PARAM_MD5: output.CHECKSUM_SCHEMA,
StageParams.PARAM_WDIR: Any(str, None),
StageParams.PARAM_DEPS: Any([dependency.SCHEMA], None),
StageParams.PARAM_OUTS: Any([output.SCHEMA], None),
StageParams.PARAM_WDIR: vol.Any(str, None),
StageParams.PARAM_DEPS: vol.Any([dependency.SCHEMA], None),
StageParams.PARAM_OUTS: vol.Any([output.SCHEMA], None),
StageParams.PARAM_LOCKED: bool, # backward compatibility
StageParams.PARAM_FROZEN: bool,
StageParams.PARAM_META: object,
StageParams.PARAM_ALWAYS_CHANGED: bool,
StageParams.PARAM_DESC: str,
}

DATA_SCHEMA = {
DATA_SCHEMA: Dict[Any, Any] = {
**CHECKSUMS_SCHEMA,
**META_SCHEMA,
Required("path"): str,
vol.Required("path"): str,
Output.PARAM_CLOUD: CLOUD_SCHEMA,
Output.PARAM_FILES: [DIR_FILES_SCHEMA],
Output.PARAM_HASH: str,
}
LOCK_FILE_STAGE_SCHEMA = {
Required(StageParams.PARAM_CMD): Any(str, list),
vol.Required(StageParams.PARAM_CMD): vol.Any(str, list),
StageParams.PARAM_DEPS: [DATA_SCHEMA],
StageParams.PARAM_PARAMS: {str: {str: object}},
StageParams.PARAM_OUTS: [DATA_SCHEMA],
}

LOCKFILE_STAGES_SCHEMA = {str: LOCK_FILE_STAGE_SCHEMA}
LOCKFILE_SCHEMA = {
Required("schema"): Equal("2.0", "invalid schema version"),
vol.Required("schema"): vol.Equal("2.0", "invalid schema version"),
STAGES: LOCKFILE_STAGES_SCHEMA,
}

Expand All @@ -70,26 +71,26 @@
Output.PARAM_PLOT_HEADER: bool,
}
PLOT_PROPS_SCHEMA = {**OUT_PSTAGE_DETAILED_SCHEMA[str], **PLOT_PROPS}
PLOT_PSTAGE_SCHEMA = {str: Any(PLOT_PROPS_SCHEMA, [PLOT_PROPS_SCHEMA])}
PLOT_PSTAGE_SCHEMA = {str: vol.Any(PLOT_PROPS_SCHEMA, [PLOT_PROPS_SCHEMA])}

PARAM_PSTAGE_NON_DEFAULT_SCHEMA = {str: [str]}

VARS_SCHEMA = [str, dict]

STAGE_DEFINITION = {
MATRIX_KWD: {str: Any(str, list)},
Required(StageParams.PARAM_CMD): Any(str, list),
Optional(StageParams.PARAM_WDIR): str,
Optional(StageParams.PARAM_DEPS): [str],
Optional(StageParams.PARAM_PARAMS): [Any(str, dict)],
Optional(VARS_KWD): VARS_SCHEMA,
Optional(StageParams.PARAM_FROZEN): bool,
Optional(StageParams.PARAM_META): object,
Optional(StageParams.PARAM_DESC): str,
Optional(StageParams.PARAM_ALWAYS_CHANGED): bool,
Optional(StageParams.PARAM_OUTS): [Any(str, OUT_PSTAGE_DETAILED_SCHEMA)],
Optional(StageParams.PARAM_METRICS): [Any(str, OUT_PSTAGE_DETAILED_SCHEMA)],
Optional(StageParams.PARAM_PLOTS): [Any(str, PLOT_PSTAGE_SCHEMA)],
MATRIX_KWD: {str: vol.Any(str, list)},
vol.Required(StageParams.PARAM_CMD): vol.Any(str, list),
vol.Optional(StageParams.PARAM_WDIR): str,
vol.Optional(StageParams.PARAM_DEPS): [str],
vol.Optional(StageParams.PARAM_PARAMS): [vol.Any(str, dict)],
vol.Optional(VARS_KWD): VARS_SCHEMA,
vol.Optional(StageParams.PARAM_FROZEN): bool,
vol.Optional(StageParams.PARAM_META): object,
vol.Optional(StageParams.PARAM_DESC): str,
vol.Optional(StageParams.PARAM_ALWAYS_CHANGED): bool,
vol.Optional(StageParams.PARAM_OUTS): [vol.Any(str, OUT_PSTAGE_DETAILED_SCHEMA)],
vol.Optional(StageParams.PARAM_METRICS): [vol.Any(str, OUT_PSTAGE_DETAILED_SCHEMA)],
vol.Optional(StageParams.PARAM_PLOTS): [vol.Any(str, PLOT_PSTAGE_SCHEMA)],
}


Expand All @@ -98,39 +99,39 @@ def validator(data):
schema = primary
if isinstance(data, Mapping) and set(fallback_includes or []) & data.keys():
schema = fallback
return Schema(schema)(data)
return vol.Schema(schema)(data)

return validator


PLOT_DEFINITION = {
Output.PARAM_PLOT_X: Any(str, {str: str}),
Output.PARAM_PLOT_Y: Any(str, [str], {str: Any(str, [str])}),
Output.PARAM_PLOT_X: vol.Any(str, {str: str}),
Output.PARAM_PLOT_Y: vol.Any(str, [str], {str: vol.Any(str, [str])}),
Output.PARAM_PLOT_X_LABEL: str,
Output.PARAM_PLOT_Y_LABEL: str,
Output.PARAM_PLOT_TITLE: str,
Output.PARAM_PLOT_TEMPLATE: str,
}
SINGLE_PLOT_SCHEMA = {str: Any(PLOT_DEFINITION, None)}
SINGLE_PLOT_SCHEMA = {str: vol.Any(PLOT_DEFINITION, None)}
ARTIFACTS = "artifacts"
SINGLE_ARTIFACT_SCHEMA = Schema({str: ARTIFACT_SCHEMA})
SINGLE_ARTIFACT_SCHEMA = vol.Schema({str: ARTIFACT_SCHEMA})
FOREACH_IN = {
Required(FOREACH_KWD): Any(dict, list, str),
Required(DO_KWD): STAGE_DEFINITION,
vol.Required(FOREACH_KWD): vol.Any(dict, list, str),
vol.Required(DO_KWD): STAGE_DEFINITION,
}
SINGLE_PIPELINE_STAGE_SCHEMA = {
str: either_or(STAGE_DEFINITION, FOREACH_IN, [FOREACH_KWD, DO_KWD])
}
MULTI_STAGE_SCHEMA = {
PLOTS: [Any(str, SINGLE_PLOT_SCHEMA)],
PLOTS: [vol.Any(str, SINGLE_PLOT_SCHEMA)],
STAGES: SINGLE_PIPELINE_STAGE_SCHEMA,
VARS_KWD: VARS_SCHEMA,
StageParams.PARAM_PARAMS: [str],
StageParams.PARAM_METRICS: [str],
ARTIFACTS: SINGLE_ARTIFACT_SCHEMA,
}

COMPILED_SINGLE_STAGE_SCHEMA = Schema(SINGLE_STAGE_SCHEMA)
COMPILED_MULTI_STAGE_SCHEMA = Schema(MULTI_STAGE_SCHEMA)
COMPILED_LOCK_FILE_STAGE_SCHEMA = Schema(LOCK_FILE_STAGE_SCHEMA)
COMPILED_LOCKFILE_SCHEMA = Schema(LOCKFILE_SCHEMA)
COMPILED_SINGLE_STAGE_SCHEMA = vol.Schema(SINGLE_STAGE_SCHEMA)
COMPILED_MULTI_STAGE_SCHEMA = vol.Schema(MULTI_STAGE_SCHEMA)
COMPILED_LOCK_FILE_STAGE_SCHEMA = vol.Schema(LOCK_FILE_STAGE_SCHEMA)
COMPILED_LOCKFILE_SCHEMA = vol.Schema(LOCKFILE_SCHEMA)
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ gdrive = ["dvc-gdrive==2.20"]
gs = ["dvc-gs==2.22.1"]
hdfs = ["dvc-hdfs==2.19"]
lint = [
"mypy==1.6.1",
"mypy==1.7.0",
"types-colorama",
"types-psutil",
"types-pyinstaller",
Expand Down

0 comments on commit 8d23a5e

Please sign in to comment.