Skip to content

Commit bef2d20

Browse files
authored
bump black in dev-requirements and pre-commit-config (#10407)
1 parent 2a26fab commit bef2d20

File tree

24 files changed

+65
-56
lines changed

24 files changed

+65
-56
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
kind: Under the Hood
2+
body: bump black to 24.3.0
3+
time: 2024-07-16T18:48:59.651834-04:00
4+
custom:
5+
Author: michelleark
6+
Issue: "10454"

.flake8

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ ignore =
77
W503 # makes Flake8 work like black
88
W504
99
E203 # makes Flake8 work like black
10+
E704 # makes Flake8 work like black
1011
E741
1112
E501 # long line checking is done in black
1213
exclude = test/

.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ repos:
2626
- id: isort
2727
- repo: https://github.com/psf/black
2828
# rev must match what's in dev-requirements.txt
29-
rev: 22.3.0
29+
rev: 24.3.0
3030
hooks:
3131
- id: black
3232
- id: black

core/dbt/artifacts/schemas/run/v5/run.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,8 @@ def compatible_previous_versions(cls) -> Iterable[Tuple[str, int]]:
158158
@classmethod
159159
def upgrade_schema_version(cls, data):
160160
"""This overrides the "upgrade_schema_version" call in VersionedSchema (via
161-
ArtifactMixin) to modify the dictionary passed in from earlier versions of the run_results."""
161+
ArtifactMixin) to modify the dictionary passed in from earlier versions of the run_results.
162+
"""
162163
run_results_schema_version = get_artifact_schema_version(data)
163164
# If less than the current version (v5), preprocess contents to match latest schema version
164165
if run_results_schema_version <= 5:

core/dbt/cli/requires.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,11 @@ def wrapper(*args, **kwargs):
179179
process_in_blocks=rusage.ru_inblock,
180180
process_out_blocks=rusage.ru_oublock,
181181
),
182-
EventLevel.INFO
183-
if "flags" in ctx.obj and ctx.obj["flags"].SHOW_RESOURCE_REPORT
184-
else None,
182+
(
183+
EventLevel.INFO
184+
if "flags" in ctx.obj and ctx.obj["flags"].SHOW_RESOURCE_REPORT
185+
else None
186+
),
185187
)
186188

187189
fire_event(

core/dbt/config/runtime.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -290,9 +290,9 @@ def get_metadata(self) -> ManifestMetadata:
290290
project_name=self.project_name,
291291
project_id=self.hashed_name(),
292292
user_id=tracking.active_user.id if tracking.active_user else None,
293-
send_anonymous_usage_stats=get_flags().SEND_ANONYMOUS_USAGE_STATS
294-
if tracking.active_user
295-
else None,
293+
send_anonymous_usage_stats=(
294+
get_flags().SEND_ANONYMOUS_USAGE_STATS if tracking.active_user else None
295+
),
296296
adapter_type=self.credentials.type,
297297
)
298298

core/dbt/context/context_config.py

+6-8
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ class ConfigSource:
2727
def __init__(self, project):
2828
self.project = project
2929

30-
def get_config_dict(self, resource_type: NodeType):
31-
...
30+
def get_config_dict(self, resource_type: NodeType): ...
3231

3332

3433
class UnrenderedConfig(ConfigSource):
@@ -130,12 +129,12 @@ def _active_project_configs(
130129
return self._project_configs(self._active_project, fqn, resource_type)
131130

132131
@abstractmethod
133-
def _update_from_config(self, result: T, partial: Dict[str, Any], validate: bool = False) -> T:
134-
...
132+
def _update_from_config(
133+
self, result: T, partial: Dict[str, Any], validate: bool = False
134+
) -> T: ...
135135

136136
@abstractmethod
137-
def initial_result(self, resource_type: NodeType, base: bool) -> T:
138-
...
137+
def initial_result(self, resource_type: NodeType, base: bool) -> T: ...
139138

140139
def calculate_node_config(
141140
self,
@@ -181,8 +180,7 @@ def calculate_node_config_dict(
181180
project_name: str,
182181
base: bool,
183182
patch_config_dict: Optional[Dict[str, Any]] = None,
184-
) -> Dict[str, Any]:
185-
...
183+
) -> Dict[str, Any]: ...
186184

187185

188186
class ContextConfigGenerator(BaseContextConfigGenerator[C]):

core/dbt/context/providers.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,7 @@ class BaseRefResolver(BaseResolver):
239239
@abc.abstractmethod
240240
def resolve(
241241
self, name: str, package: Optional[str] = None, version: Optional[NodeVersion] = None
242-
) -> RelationProxy:
243-
...
242+
) -> RelationProxy: ...
244243

245244
def _repack_args(
246245
self, name: str, package: Optional[str], version: Optional[NodeVersion]
@@ -306,8 +305,7 @@ def __call__(self, *args: str) -> RelationProxy:
306305

307306
class BaseMetricResolver(BaseResolver):
308307
@abc.abstractmethod
309-
def resolve(self, name: str, package: Optional[str] = None) -> MetricReference:
310-
...
308+
def resolve(self, name: str, package: Optional[str] = None) -> MetricReference: ...
311309

312310
def _repack_args(self, name: str, package: Optional[str]) -> List[str]:
313311
if package is None:
@@ -341,8 +339,7 @@ def __call__(self, *args: str) -> MetricReference:
341339

342340

343341
class Config(Protocol):
344-
def __init__(self, model, context_config: Optional[ContextConfig]):
345-
...
342+
def __init__(self, model, context_config: Optional[ContextConfig]): ...
346343

347344

348345
# Implementation of "config(..)" calls in models

core/dbt/contracts/graph/manifest.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1676,9 +1676,9 @@ def __init__(self, macros) -> None:
16761676
self.macros = macros
16771677
self.metadata = ManifestMetadata(
16781678
user_id=tracking.active_user.id if tracking.active_user else None,
1679-
send_anonymous_usage_stats=get_flags().SEND_ANONYMOUS_USAGE_STATS
1680-
if tracking.active_user
1681-
else None,
1679+
send_anonymous_usage_stats=(
1680+
get_flags().SEND_ANONYMOUS_USAGE_STATS if tracking.active_user else None
1681+
),
16821682
)
16831683
# This is returned by the 'graph' context property
16841684
# in the ProviderContext class.

core/dbt/contracts/graph/nodes.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -636,9 +636,9 @@ def same_contract(self, old, adapter_type=None) -> bool:
636636
contract_enforced_disabled: bool = False
637637
columns_removed: List[str] = []
638638
column_type_changes: List[Dict[str, str]] = []
639-
enforced_column_constraint_removed: List[
640-
Dict[str, str]
641-
] = [] # column_name, constraint_type
639+
enforced_column_constraint_removed: List[Dict[str, str]] = (
640+
[]
641+
) # column_name, constraint_type
642642
enforced_model_constraint_removed: List[Dict[str, Any]] = [] # constraint_type, columns
643643
materialization_changed: List[str] = []
644644

@@ -1554,7 +1554,7 @@ def same_exports(self, old: "SavedQuery") -> bool:
15541554
return False
15551555

15561556
# exports should be in the same order, so we zip them for easy iteration
1557-
for (old_export, new_export) in zip(old.exports, self.exports):
1557+
for old_export, new_export in zip(old.exports, self.exports):
15581558
if not (
15591559
old_export.name == new_export.name
15601560
and old_export.config.export_as == new_export.config.export_as

core/dbt/events/logging.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,7 @@ def setup_event_logger(flags, callbacks: List[Callable[[EventMsg], None]] = [])
7474
log_level = (
7575
EventLevel.ERROR
7676
if flags.QUIET
77-
else EventLevel.DEBUG
78-
if flags.DEBUG
79-
else EventLevel(flags.LOG_LEVEL)
77+
else EventLevel.DEBUG if flags.DEBUG else EventLevel(flags.LOG_LEVEL)
8078
)
8179
console_config = get_stdout_config(
8280
line_format,

core/dbt/parser/models.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ def parse_python_model(self, node, config, context):
204204
dbt_parser = PythonParseVisitor(node)
205205
dbt_parser.visit(tree)
206206

207-
for (func, args, kwargs) in dbt_parser.dbt_function_calls:
207+
for func, args, kwargs in dbt_parser.dbt_function_calls:
208208
if func == "get":
209209
num_args = len(args)
210210
if num_args == 0:

core/dbt/task/base.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -274,9 +274,11 @@ def from_run_result(self, result, start_time, timing_info):
274274

275275
def compile_and_execute(self, manifest, ctx):
276276
result = None
277-
with self.adapter.connection_named(
278-
self.node.unique_id, self.node
279-
) if get_flags().INTROSPECT else nullcontext():
277+
with (
278+
self.adapter.connection_named(self.node.unique_id, self.node)
279+
if get_flags().INTROSPECT
280+
else nullcontext()
281+
):
280282
ctx.node.update_event_status(node_status=RunningStatus.Compiling)
281283
fire_event(
282284
NodeCompiling(

core/dbt/tests/fixtures/project.py

+1
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ def write_project_files_recursively(path, file_dict):
341341
# Provide a dictionary of file names to contents. Nested directories
342342
# are handle by nested dictionaries.
343343

344+
344345
# models directory
345346
@pytest.fixture(scope="class")
346347
def models():

core/dbt/tests/util.py

+1
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ class TestProcessingException(Exception):
291291

292292
# Testing utilities that use adapter code
293293

294+
294295
# Uses:
295296
# adapter.config.credentials
296297
# adapter.quote

dev-requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ git+https://github.com/dbt-labs/dbt-adapters.git@main#subdirectory=dbt-tests-ada
33
git+https://github.com/dbt-labs/dbt-common.git@main
44
git+https://github.com/dbt-labs/dbt-postgres.git@main
55
# black must match what's in .pre-commit-config.yaml to be sure local env matches CI
6-
black==22.3.0
6+
black==24.3.0
77
bumpversion
88
ddtrace==2.3.0
99
docutils

tests/functional/adapter/constraints/test_constraints.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def test__constraints_wrong_column_names(self, project, string_type, int_type):
104104
def test__constraints_wrong_column_data_types(
105105
self, project, string_type, int_type, schema_string_type, schema_int_type, data_types
106106
):
107-
for (sql_column_value, schema_data_type, error_data_type) in data_types:
107+
for sql_column_value, schema_data_type, error_data_type in data_types:
108108
# Write parametrized data_type to sql file
109109
write_file(
110110
my_model_data_type_sql.format(sql_value=sql_column_value),
@@ -146,7 +146,7 @@ def test__constraints_wrong_column_data_types(
146146
assert all([(exp in log_output or exp.upper() in log_output) for exp in expected])
147147

148148
def test__constraints_correct_column_data_types(self, project, data_types):
149-
for (sql_column_value, schema_data_type, _) in data_types:
149+
for sql_column_value, schema_data_type, _ in data_types:
150150
# Write parametrized data_type to sql file
151151
write_file(
152152
my_model_data_type_sql.format(sql_value=sql_column_value),

tests/functional/list/test_list.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -697,9 +697,9 @@ def expect_resource_type_env_var(self):
697697
"test.unique_outer_id",
698698
}
699699
del os.environ["DBT_RESOURCE_TYPES"]
700-
os.environ[
701-
"DBT_EXCLUDE_RESOURCE_TYPES"
702-
] = "test saved_query metric source semantic_model snapshot seed"
700+
os.environ["DBT_EXCLUDE_RESOURCE_TYPES"] = (
701+
"test saved_query metric source semantic_model snapshot seed"
702+
)
703703
results = self.run_dbt_ls()
704704
assert set(results) == {
705705
"test.ephemeral",

tests/unit/parser/test_manifest.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,9 @@ def set_required_mocks(
124124
mocker.patch("dbt.parser.manifest.get_adapter").return_value = mock_adapter
125125
mocker.patch("dbt.parser.manifest.ManifestLoader.load").return_value = manifest
126126
mocker.patch("dbt.parser.manifest._check_manifest").return_value = None
127-
mocker.patch(
128-
"dbt.parser.manifest.ManifestLoader.save_macros_to_adapter"
129-
).return_value = None
127+
mocker.patch("dbt.parser.manifest.ManifestLoader.save_macros_to_adapter").return_value = (
128+
None
129+
)
130130
mocker.patch("dbt.tracking.active_user").return_value = User(None)
131131

132132
def test_write_perf_info(

tests/unit/parser/test_partial.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,9 @@ class TestFileDiff:
193193
def partial_parsing(self, manifest, files):
194194
safe_set_invocation_context()
195195
saved_files = deepcopy(files)
196-
saved_files[
197-
"my_test://models/python_model_untouched.py"
198-
].checksum = FileHash.from_contents("something new")
196+
saved_files["my_test://models/python_model_untouched.py"].checksum = (
197+
FileHash.from_contents("something new")
198+
)
199199
return PartialParsing(manifest, saved_files)
200200

201201
def test_build_file_diff_basic(self, partial_parsing):

tests/unit/test_compilation.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def _get_graph_queue(
8585
def test_linker_add_dependency(self, linker: Linker) -> None:
8686
actual_deps = [("A", "B"), ("A", "C"), ("B", "C")]
8787

88-
for (l, r) in actual_deps:
88+
for l, r in actual_deps:
8989
linker.dependency(l, r)
9090

9191
queue = self._get_graph_queue(_mock_manifest("ABC"), linker)
@@ -119,7 +119,7 @@ def test_linker_add_disjoint_dependencies(self, linker: Linker) -> None:
119119
actual_deps = [("A", "B")]
120120
additional_node = "Z"
121121

122-
for (l, r) in actual_deps:
122+
for l, r in actual_deps:
123123
linker.dependency(l, r)
124124
linker.add_node(additional_node)
125125

@@ -150,7 +150,7 @@ def test_linker_add_disjoint_dependencies(self, linker: Linker) -> None:
150150
def test_linker_dependencies_limited_to_some_nodes(self, linker: Linker) -> None:
151151
actual_deps = [("A", "B"), ("B", "C"), ("C", "D")]
152152

153-
for (l, r) in actual_deps:
153+
for l, r in actual_deps:
154154
linker.dependency(l, r)
155155

156156
queue = self._get_graph_queue(_mock_manifest("ABCD"), linker, ["B"])
@@ -181,15 +181,15 @@ def test_linker_dependencies_limited_to_some_nodes(self, linker: Linker) -> None
181181
def test__find_cycles__cycles(self, linker: Linker) -> None:
182182
actual_deps = [("A", "B"), ("B", "C"), ("C", "A")]
183183

184-
for (l, r) in actual_deps:
184+
for l, r in actual_deps:
185185
linker.dependency(l, r)
186186

187187
assert linker.find_cycles() is not None
188188

189189
def test__find_cycles__no_cycles(self, linker: Linker) -> None:
190190
actual_deps = [("A", "B"), ("B", "C"), ("C", "D")]
191191

192-
for (l, r) in actual_deps:
192+
for l, r in actual_deps:
193193
linker.dependency(l, r)
194194

195195
assert linker.find_cycles() is None

tests/unit/utils/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
Note that all imports should be inside the functions to avoid import/mocking
44
issues.
55
"""
6+
67
import os
78
import string
89
from unittest import TestCase, mock

tests/unit/utils/adapter.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ def postgres_adapter(
4242
adapter = get_adapter(runtime_config)
4343
assert isinstance(adapter, PostgresAdapter)
4444

45-
mocker.patch(
46-
"dbt.parser.manifest.ManifestLoader.build_manifest_state_check"
47-
).return_value = ManifestStateCheck()
45+
mocker.patch("dbt.parser.manifest.ManifestLoader.build_manifest_state_check").return_value = (
46+
ManifestStateCheck()
47+
)
4848
manifest = ManifestLoader.load_macros(
4949
runtime_config,
5050
adapter.connections.set_query_header,

third-party-stubs/mashumaro/jsonschema/models.pyi

+1
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ class JSONSchema(DataClassJSONMixin):
106106
serialize_by_alias: bool
107107
aliases: Incomplete
108108
serialization_strategy: Incomplete
109+
109110
def __pre_serialize__(self, context: Optional[Dict]) -> JSONSchema: ...
110111
def __post_serialize__(self, d: Dict[Any, Any], context: Optional[Dict]) -> Dict[Any, Any]: ...
111112
def __init__(

0 commit comments

Comments
 (0)