Skip to content

Commit

Permalink
Bump mypy from 0.981 to 1.0.1 (#7027)
Browse files Browse the repository at this point in the history
* Bump mypy from 0.981 to 1.0.1

Bumps [mypy](https://github.com/python/mypy) from 0.981 to 1.0.1.
- [Release notes](https://github.com/python/mypy/releases)
- [Commits](python/mypy@v0.981...v1.0.1)

---
updated-dependencies:
- dependency-name: mypy
  dependency-type: direct:development
  update-type: version-update:semver-major
...

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

* Add automated changelog yaml from template for bot PR

* upgrade mypy and fix all errors

* fixing some duplicate imports from conflict resolution

* fix mypy errors from merging in main

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Github Build Bot <[email protected]>
Co-authored-by: Emily Rockman <[email protected]>
  • Loading branch information
3 people authored Jun 14, 2023
1 parent f16bae0 commit ae97831
Show file tree
Hide file tree
Showing 19 changed files with 52 additions and 32 deletions.
6 changes: 6 additions & 0 deletions .changes/unreleased/Dependencies-20230222-162807.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: "Dependencies"
body: "Bump mypy from 0.981 to 1.0.1"
time: 2023-02-22T16:28:07.00000Z
custom:
Author: dependabot[bot]
PR: 7027
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ repos:
alias: flake8-check
stages: [manual]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.981
rev: v1.3.0
hooks:
- id: mypy
# N.B.: Mypy is... a bit fragile.
Expand Down
6 changes: 3 additions & 3 deletions core/dbt/adapters/base/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ def _get_catalog_schemas(self, manifest: Manifest) -> SchemaSearchMap:
return info_schema_name_map

def _relations_cache_for_schemas(
self, manifest: Manifest, cache_schemas: Set[BaseRelation] = None
self, manifest: Manifest, cache_schemas: Optional[Set[BaseRelation]] = None
) -> None:
"""Populate the relations cache for the given schemas. Returns an
iterable of the schemas populated, as strings.
Expand Down Expand Up @@ -451,7 +451,7 @@ def set_relations_cache(
self,
manifest: Manifest,
clear: bool = False,
required_schemas: Set[BaseRelation] = None,
required_schemas: Optional[Set[BaseRelation]] = None,
) -> None:
"""Run a query that gets a populated cache of the relations in the
database and set the cache on this adapter.
Expand Down Expand Up @@ -986,7 +986,7 @@ def execute_macro(
manifest: Optional[Manifest] = None,
project: Optional[str] = None,
context_override: Optional[Dict[str, Any]] = None,
kwargs: Dict[str, Any] = None,
kwargs: Optional[Dict[str, Any]] = None,
text_only_columns: Optional[Iterable[str]] = None,
) -> AttrDict:
"""Look macro_name up in the manifest and execute its results.
Expand Down
4 changes: 3 additions & 1 deletion core/dbt/cli/flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ def args_to_context(args: List[str]) -> Context:
class Flags:
"""Primary configuration artifact for running dbt"""

def __init__(self, ctx: Context = None, user_config: UserConfig = None) -> None:
def __init__(
self, ctx: Optional[Context] = None, user_config: Optional[UserConfig] = None
) -> None:

# Set the default flags.
for key, value in FLAGS_DEFAULTS.items():
Expand Down
4 changes: 2 additions & 2 deletions core/dbt/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ class dbtRunnerResult:
class dbtRunner:
def __init__(
self,
manifest: Manifest = None,
callbacks: List[Callable[[EventMsg], None]] = None,
manifest: Optional[Manifest] = None,
callbacks: Optional[List[Callable[[EventMsg], None]]] = None,
):
self.manifest = manifest

Expand Down
4 changes: 3 additions & 1 deletion core/dbt/context/configured.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ def var(self) -> ConfiguredVar:


def generate_schema_yml_context(
config: AdapterRequiredConfig, project_name: str, schema_yaml_vars: SchemaYamlVars = None
config: AdapterRequiredConfig,
project_name: str,
schema_yaml_vars: Optional[SchemaYamlVars] = None,
) -> Dict[str, Any]:
ctx = SchemaYamlContext(config, project_name, schema_yaml_vars)
return ctx.to_dict()
Expand Down
16 changes: 10 additions & 6 deletions core/dbt/context/context_config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from abc import abstractmethod
from copy import deepcopy
from dataclasses import dataclass
from typing import List, Iterator, Dict, Any, TypeVar, Generic
from typing import List, Iterator, Dict, Any, TypeVar, Generic, Optional

from dbt.config import RuntimeConfig, Project, IsFQNResource
from dbt.contracts.graph.model_config import BaseConfig, get_config_for, _listify
Expand Down Expand Up @@ -130,7 +130,7 @@ def calculate_node_config(
resource_type: NodeType,
project_name: str,
base: bool,
patch_config_dict: Dict[str, Any] = None,
patch_config_dict: Optional[Dict[str, Any]] = None,
) -> BaseConfig:
own_config = self.get_node_project(project_name)

Expand Down Expand Up @@ -166,7 +166,7 @@ def calculate_node_config_dict(
resource_type: NodeType,
project_name: str,
base: bool,
patch_config_dict: Dict[str, Any],
patch_config_dict: Optional[Dict[str, Any]] = None,
) -> Dict[str, Any]:
...

Expand Down Expand Up @@ -200,7 +200,7 @@ def calculate_node_config_dict(
resource_type: NodeType,
project_name: str,
base: bool,
patch_config_dict: dict = None,
patch_config_dict: Optional[dict] = None,
) -> Dict[str, Any]:
config = self.calculate_node_config(
config_call_dict=config_call_dict,
Expand All @@ -225,7 +225,7 @@ def calculate_node_config_dict(
resource_type: NodeType,
project_name: str,
base: bool,
patch_config_dict: dict = None,
patch_config_dict: Optional[dict] = None,
) -> Dict[str, Any]:
# TODO CT-211
return self.calculate_node_config(
Expand Down Expand Up @@ -318,7 +318,11 @@ def _add_config_call(cls, config_call_dict, opts: Dict[str, Any]) -> None:
config_call_dict[k] = v

def build_config_dict(
self, base: bool = False, *, rendered: bool = True, patch_config_dict: dict = None
self,
base: bool = False,
*,
rendered: bool = True,
patch_config_dict: Optional[dict] = None,
) -> Dict[str, Any]:
if rendered:
# TODO CT-211
Expand Down
1 change: 1 addition & 0 deletions core/dbt/context/providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ def __call__(self, *args: str) -> RelationProxy:


class BaseMetricResolver(BaseResolver):
@abc.abstractmethod
def resolve(self, name: str, package: Optional[str] = None) -> MetricReference:
...

Expand Down
3 changes: 2 additions & 1 deletion core/dbt/events/base_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from google.protobuf.json_format import ParseDict, MessageToDict, MessageToJson
from google.protobuf.message import Message
from dbt.events.helpers import get_json_string_utcnow
from typing import Optional

if sys.version_info >= (3, 8):
from typing import Protocol
Expand Down Expand Up @@ -126,7 +127,7 @@ class EventMsg(Protocol):
data: Message


def msg_from_base_event(event: BaseEvent, level: EventLevel = None):
def msg_from_base_event(event: BaseEvent, level: Optional[EventLevel] = None):

msg_class_name = f"{type(event).__name__}Msg"
msg_cls = getattr(types_pb2, msg_class_name)
Expand Down
2 changes: 1 addition & 1 deletion core/dbt/events/eventmgr.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def __init__(self) -> None:
self.callbacks: List[Callable[[EventMsg], None]] = []
self.invocation_id: str = str(uuid4())

def fire_event(self, e: BaseEvent, level: EventLevel = None) -> None:
def fire_event(self, e: BaseEvent, level: Optional[EventLevel] = None) -> None:
msg = msg_from_base_event(e, level=level)

if os.environ.get("DBT_TEST_BINARY_SERIALIZATION"):
Expand Down
8 changes: 5 additions & 3 deletions core/dbt/events/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,22 +247,24 @@ def warn_or_error(event, node=None):
# an alternative to fire_event which only creates and logs the event value
# if the condition is met. Does nothing otherwise.
def fire_event_if(
conditional: bool, lazy_e: Callable[[], BaseEvent], level: EventLevel = None
conditional: bool, lazy_e: Callable[[], BaseEvent], level: Optional[EventLevel] = None
) -> None:
if conditional:
fire_event(lazy_e(), level=level)


# a special case of fire_event_if, to only fire events in our unit/functional tests
def fire_event_if_test(lazy_e: Callable[[], BaseEvent], level: EventLevel = None) -> None:
def fire_event_if_test(
lazy_e: Callable[[], BaseEvent], level: Optional[EventLevel] = None
) -> None:
fire_event_if(conditional=("pytest" in sys.modules), lazy_e=lazy_e, level=level)


# top-level method for accessing the new eventing system
# this is where all the side effects happen branched by event type
# (i.e. - mutating the event history, printing to stdout, logging
# to files, etc.)
def fire_event(e: BaseEvent, level: EventLevel = None) -> None:
def fire_event(e: BaseEvent, level: Optional[EventLevel] = None) -> None:
EVENT_MANAGER.fire_event(e, level=level)


Expand Down
4 changes: 2 additions & 2 deletions core/dbt/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ def message(self):


class SemverError(Exception):
def __init__(self, msg: str = None):
def __init__(self, msg: Optional[str] = None):
self.msg = msg
if msg is not None:
super().__init__(msg)
Expand Down Expand Up @@ -2419,7 +2419,7 @@ class RPCCompiling(DbtRuntimeError):
CODE = 10010
MESSAGE = 'RPC server is compiling the project, call the "status" method for' " compile status"

def __init__(self, msg: str = None, node=None):
def __init__(self, msg: Optional[str] = None, node=None):
if msg is None:
msg = "compile in progress"
super().__init__(msg, node)
Expand Down
2 changes: 1 addition & 1 deletion core/dbt/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ class ListLogHandler(LogMessageHandler):
def __init__(
self,
level: int = logbook.NOTSET,
filter: Callable = None,
filter: Optional[Callable] = None,
bubble: bool = False,
lst: Optional[List[LogMessage]] = None,
) -> None:
Expand Down
2 changes: 1 addition & 1 deletion core/dbt/parser/generic_test_builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def __init__(
target: Testable,
package_name: str,
render_ctx: Dict[str, Any],
column_name: str = None,
column_name: Optional[str] = None,
version: Optional[NodeVersion] = None,
) -> None:
test_name, test_args = self.extract_test_args(test, column_name)
Expand Down
2 changes: 1 addition & 1 deletion core/dbt/parser/schema_generic_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def resource_type(self) -> NodeType:
def get_compiled_path(cls, block: FileBlock) -> str:
return block.path.relative_path

def parse_file(self, block: FileBlock, dct: Dict = None) -> None:
def parse_file(self, block: FileBlock, dct: Optional[Dict] = None) -> None:
pass

def parse_from_dict(self, dct, validate=True) -> GenericTestNode:
Expand Down
2 changes: 1 addition & 1 deletion core/dbt/parser/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def get_compiled_path(cls, block: FileBlock) -> str:
def resource_type(self) -> NodeType:
return NodeType.Test

def parse_file(self, block: FileBlock, dct: Dict = None) -> None:
def parse_file(self, block: FileBlock, dct: Optional[Dict] = None) -> None:
assert isinstance(block.file, SchemaSourceFile)

# If partially parsing, dct should be from pp_dict, otherwise
Expand Down
4 changes: 3 additions & 1 deletion core/dbt/task/runnable.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,9 @@ def _mark_dependent_errors(self, node_id, result, cause):
for dep_node_id in self.graph.get_dependent_nodes(node_id):
self._skipped_children[dep_node_id] = cause

def populate_adapter_cache(self, adapter, required_schemas: Set[BaseRelation] = None):
def populate_adapter_cache(
self, adapter, required_schemas: Optional[Set[BaseRelation]] = None
):
if not self.args.populate_cache:
return

Expand Down
10 changes: 5 additions & 5 deletions core/dbt/tests/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import json
import warnings
from datetime import datetime
from typing import Dict, List
from typing import Dict, List, Optional
from contextlib import contextmanager
from dbt.adapters.factory import Adapter

Expand Down Expand Up @@ -71,9 +71,9 @@
# If the command is expected to fail, pass in "expect_pass=False"):
# run_dbt("test"], expect_pass=False)
def run_dbt(
args: List[str] = None,
args: Optional[List[str]] = None,
expect_pass: bool = True,
publications: List[PublicationArtifact] = None,
publications: Optional[List[PublicationArtifact]] = None,
):
# Ignore logbook warnings
warnings.filterwarnings("ignore", category=DeprecationWarning, module="logbook")
Expand Down Expand Up @@ -117,9 +117,9 @@ def run_dbt(
# start with the "--debug" flag. The structured schema log CI test
# will turn the logs into json, so you have to be prepared for that.
def run_dbt_and_capture(
args: List[str] = None,
args: Optional[List[str]] = None,
expect_pass: bool = True,
publications: List[PublicationArtifact] = None,
publications: Optional[List[PublicationArtifact]] = None,
):
try:
stringbuf = StringIO()
Expand Down
2 changes: 1 addition & 1 deletion dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ flake8
flaky
freezegun==0.3.12
ipdb
mypy==0.981
mypy==1.3.0
pip-tools
pre-commit
protobuf>=4.0.0
Expand Down

0 comments on commit ae97831

Please sign in to comment.