Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add typing to DepsTask.run #6192

Merged
merged 1 commit into from
Nov 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/dbt/deps/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def _fetch_metadata(self, project, renderer):
raise NotImplementedError

@abc.abstractmethod
def install(self, project):
def install(self, project, renderer):
raise NotImplementedError

@abc.abstractmethod
Expand Down
2 changes: 1 addition & 1 deletion core/dbt/events/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -1706,7 +1706,7 @@ def code(self):
def message(self) -> str:
return "Updates available for packages: {} \
\nUpdate your versions in packages.yml, then run dbt deps".format(
self.packages
self.packages.value
)


Expand Down
14 changes: 10 additions & 4 deletions core/dbt/task/deps.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import Optional

import dbt.utils
import dbt.deprecations
import dbt.exceptions
Expand All @@ -6,7 +8,9 @@
from dbt.config.renderer import DbtProjectYamlRenderer
from dbt.deps.base import downloads_directory
from dbt.deps.resolver import resolve_packages
from dbt.deps.registry import RegistryPinnedPackage

from dbt.events.proto_types import ListOfStrings
from dbt.events.functions import fire_event
from dbt.events.types import (
DepsNoPackagesFound,
Expand All @@ -29,7 +33,9 @@ class DepsTask(BaseTask):
def __init__(self, args, config: UnsetProfileConfig):
super().__init__(args=args, config=config)

def track_package_install(self, package_name: str, source_type: str, version: str) -> None:
def track_package_install(
self, package_name: str, source_type: str, version: Optional[str]
) -> None:
# Hub packages do not need to be hashed, as they are public
# Use the string 'local' for local package versions
if source_type == "local":
Expand All @@ -45,7 +51,7 @@ def track_package_install(self, package_name: str, source_type: str, version: st
{"name": package_name, "source": source_type, "version": version},
)

def run(self):
def run(self) -> None:
system.make_directory(self.config.packages_install_path)
packages = self.config.packages.packages
if not packages:
Expand All @@ -66,7 +72,7 @@ def run(self):
fire_event(DepsStartPackageInstall(package_name=package_name))
package.install(self.config, renderer)
fire_event(DepsInstallInfo(version_name=package.nice_version_name()))
if source_type == "hub":
if isinstance(package, RegistryPinnedPackage):
version_latest = package.get_version_latest()
if version_latest != version:
packages_to_upgrade.append(package_name)
Expand All @@ -81,7 +87,7 @@ def run(self):
)
if packages_to_upgrade:
fire_event(EmptyLine())
fire_event(DepsNotifyUpdatesAvailable(packages=packages_to_upgrade))
fire_event(DepsNotifyUpdatesAvailable(packages=ListOfStrings(packages_to_upgrade)))

@classmethod
def from_args(cls, args):
Expand Down
5 changes: 3 additions & 2 deletions tests/unit/test_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
ErrorLevel,
TestLevel,
)
from dbt.events.proto_types import NodeInfo, RunResultMsg, ReferenceKeyMsg
from dbt.events.proto_types import ListOfStrings, NodeInfo, RunResultMsg, ReferenceKeyMsg
from importlib import reload
import dbt.events.functions as event_funcs
import dbt.flags as flags
Expand Down Expand Up @@ -321,7 +321,8 @@ def MockNode():
DepsInstallInfo(version_name=""),
DepsUpdateAvailable(version_latest=""),
DepsListSubdirectory(subdirectory=""),
DepsNotifyUpdatesAvailable(packages=[]),
DepsNotifyUpdatesAvailable(packages=ListOfStrings()),
DepsNotifyUpdatesAvailable(packages=ListOfStrings(['dbt-utils'])),
DatabaseErrorRunningHook(hook_type=""),
EmptyLine(),
HooksRunning(num_hooks=0, hook_type=""),
Expand Down