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

f-string cleanup #6068 #6082

Merged
merged 4 commits into from
Oct 17, 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
7 changes: 7 additions & 0 deletions .changes/unreleased/Under the Hood-20221017-155844.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
kind: Under the Hood
body: Clean up string formatting
time: 2022-10-17T15:58:44.676549-04:00
custom:
Author: eve-johns
Issue: "6068"
PR: "6082"
2 changes: 1 addition & 1 deletion core/dbt/config/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ def hashed_name(self):
def get_selector(self, name: str) -> Union[SelectionSpec, bool]:
if name not in self.selectors:
raise RuntimeException(
f"Could not find selector named {name}, expected one of " f"{list(self.selectors)}"
f"Could not find selector named {name}, expected one of {list(self.selectors)}"
)
return self.selectors[name]["definition"]

Expand Down
6 changes: 3 additions & 3 deletions core/dbt/context/providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def dispatch(
return macro

searched = ", ".join(repr(a) for a in attempts)
msg = f"In dispatch: No macro named '{macro_name}' found\n" f" Searched for: {searched}"
msg = f"In dispatch: No macro named '{macro_name}' found\n Searched for: {searched}"
raise CompilationException(msg)


Expand Down Expand Up @@ -220,12 +220,12 @@ def _repack_args(self, name: str, package: Optional[str]) -> List[str]:
def validate_args(self, name: str, package: Optional[str]):
if not isinstance(name, str):
raise CompilationException(
f"The name argument to ref() must be a string, got " f"{type(name)}"
f"The name argument to ref() must be a string, got {type(name)}"
)

if package is not None and not isinstance(package, str):
raise CompilationException(
f"The package argument to ref() must be a string or None, got " f"{type(package)}"
f"The package argument to ref() must be a string or None, got {type(package)}"
)

def __call__(self, *args: str) -> RelationProxy:
Expand Down
2 changes: 1 addition & 1 deletion core/dbt/contracts/graph/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ def _update_into(dest: MutableMapping[str, T], new_item: T):
existing = dest[unique_id]
if new_item.original_file_path != existing.original_file_path:
raise dbt.exceptions.RuntimeException(
f"cannot update a {new_item.resource_type} to have a new file " f"path!"
f"cannot update a {new_item.resource_type} to have a new file path!"
)
dest[unique_id] = new_item

Expand Down
4 changes: 1 addition & 3 deletions core/dbt/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -976,9 +976,7 @@ def raise_patch_targets_not_found(patches):

def _fix_dupe_msg(path_1: str, path_2: str, name: str, type_name: str) -> str:
if path_1 == path_2:
return (
f"remove one of the {type_name} entries for {name} in this file:\n" f" - {path_1!s}\n"
)
return f"remove one of the {type_name} entries for {name} in this file:\n - {path_1!s}\n"
else:
return (
f"remove the {type_name} entry for {name} in one of these files:\n"
Expand Down
2 changes: 1 addition & 1 deletion core/dbt/graph/selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def get_package_names(nodes):

def alert_non_existence(raw_spec, nodes):
if len(nodes) == 0:
warn_or_error(f"The selection criterion '{str(raw_spec)}' does not match" f" any nodes")
warn_or_error(f"The selection criterion '{str(raw_spec)}' does not match any nodes")


def can_select_indirectly(node):
Expand Down
2 changes: 1 addition & 1 deletion core/dbt/parser/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ def initial_config(self, fqn: List[str]) -> ContextConfig:
)
else:
raise InternalException(
f"Got an unexpected project version={config_version}, " f"expected 2"
f"Got an unexpected project version={config_version}, expected 2"
)

def config_dict(
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 @@ -435,7 +435,7 @@ def tags(self) -> List[str]:
tags = [tags]
if not isinstance(tags, list):
raise_compiler_error(
f"got {tags} ({type(tags)}) for tags, expected a list of " f"strings"
f"got {tags} ({type(tags)}) for tags, expected a list of strings"
)
for tag in tags:
if not isinstance(tag, str):
Expand Down
2 changes: 1 addition & 1 deletion core/dbt/parser/sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def parse_source(self, target: UnpatchedSourceDefinition) -> ParsedSourceDefinit

if not isinstance(config, SourceConfig):
raise InternalException(
f"Calculated a {type(config)} for a source, but expected " f"a SourceConfig"
f"Calculated a {type(config)} for a source, but expected a SourceConfig"
)

default_database = self.root_project.credentials.database
Expand Down
2 changes: 1 addition & 1 deletion core/dbt/task/runnable.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def _runtime_initialize(self):
self._flattened_nodes.append(self.manifest.sources[uid])
else:
raise InternalException(
f"Node selection returned {uid}, expected a node or a " f"source"
f"Node selection returned {uid}, expected a node or a source"
)

self.num_nodes = len([n for n in self._flattened_nodes if not n.is_ephemeral_model])
Expand Down