Skip to content

Commit

Permalink
add typing (#10619)
Browse files Browse the repository at this point in the history
  • Loading branch information
emmyoop authored Aug 28, 2024
1 parent f7d21e0 commit d652359
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions core/dbt/cli/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
from typing import IO, Optional
from typing import IO, List, Optional, Union

from click.exceptions import ClickException

from dbt.artifacts.schemas.catalog import CatalogArtifact
from dbt.contracts.graph.manifest import Manifest
from dbt.contracts.results import RunExecutionResult
from dbt.utils import ExitCodes


Expand All @@ -23,15 +26,25 @@ def __init__(self, exit_code: ExitCodes) -> None:

# the typing of _file is to satisfy the signature of ClickException.show
# overriding this method prevents click from printing any exceptions to stdout
def show(self, _file: Optional[IO] = None) -> None:
def show(self, _file: Optional[IO] = None) -> None: # type: ignore[type-arg]
pass


class ResultExit(CliException):
"""This class wraps any exception that contains results while invoking dbt, or the
results of an invocation that did not succeed but did not throw any exceptions."""

def __init__(self, result) -> None:
def __init__(
self,
result: Union[
bool, # debug
CatalogArtifact, # docs generate
List[str], # list/ls
Manifest, # parse
None, # clean, deps, init, source
RunExecutionResult, # build, compile, run, seed, snapshot, test, run-operation
] = None,
) -> None:
super().__init__(ExitCodes.ModelError)
self.result = result

Expand Down

0 comments on commit d652359

Please sign in to comment.