Skip to content

Commit 2fa46f3

Browse files
committed
adding ClassVar per Jon's suggestions
1 parent efe7e90 commit 2fa46f3

File tree

2 files changed

+38
-23
lines changed

2 files changed

+38
-23
lines changed

nodestream/cli/commands/print_schema.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
from cleo.helpers import option
1+
from typing import ClassVar
2+
3+
from cleo.helpers import argument, option
24

35
from ..operations import InitializeProject, PrintProjectSchema
46
from .nodestream_command import NodestreamCommand
@@ -8,7 +10,7 @@
810
class PrintSchema(NodestreamCommand):
911
name = "print schema"
1012
description = "Print the schema for the current project"
11-
arguments = [MANY_PIPELINES_ARGUMENT]
13+
arguments: ClassVar[list[argument]] = [MANY_PIPELINES_ARGUMENT]
1214
options = [
1315
PROJECT_FILE_OPTION,
1416
option(

tests/unit/project/test_project.py

Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -379,25 +379,31 @@ def test_project_get_from_storage(project, mocker):
379379
same_instance(project.storage_configuration.initialize_by_name.return_value),
380380
)
381381

382+
382383
def test_get_pipelines_schema_multiple_pipelines(project, mocker):
383384
mock_schema = mocker.Mock(spec=Schema)
384385
mock_coordinator = mocker.Mock()
385386
mock_coordinator.schema = mock_schema
386387

387-
mocker.patch('nodestream.project.project.SchemaExpansionCoordinator', return_value=mock_coordinator)
388-
388+
mocker.patch(
389+
"nodestream.project.project.SchemaExpansionCoordinator",
390+
return_value=mock_coordinator,
391+
)
392+
389393
mock_pipeline1 = mocker.Mock()
390394
mock_pipeline1.initialize_for_introspection = mocker.Mock()
391395
mock_pipeline1.expand_schema = mocker.Mock()
392-
396+
393397
mock_pipeline2 = mocker.Mock()
394398
mock_pipeline2.initialize_for_introspection = mocker.Mock()
395399
mock_pipeline2.expand_schema = mocker.Mock()
396-
397-
mocker.patch.object(project, 'get_pipeline_by_names', return_value=[mock_pipeline1, mock_pipeline2])
398-
400+
401+
mocker.patch.object(
402+
project, "get_pipeline_by_names", return_value=[mock_pipeline1, mock_pipeline2]
403+
)
404+
399405
result = project.get_pipelines_schema(["test", "test2"])
400-
406+
401407
mock_pipeline1.initialize_for_introspection.assert_called_once()
402408
mock_pipeline1.expand_schema.assert_called_once_with(coordinator=mock_coordinator)
403409
mock_pipeline2.initialize_for_introspection.assert_called_once()
@@ -410,37 +416,44 @@ def test_get_pipelines_schema_with_type_overrides(project, mocker):
410416
mock_overrides_schema = mocker.Mock(spec=Schema)
411417
mock_coordinator = mocker.Mock()
412418
mock_coordinator.schema = mock_base_schema
413-
414-
mocker.patch('nodestream.project.project.SchemaExpansionCoordinator', return_value=mock_coordinator)
419+
420+
mocker.patch(
421+
"nodestream.project.project.SchemaExpansionCoordinator",
422+
return_value=mock_coordinator,
423+
)
415424
Schema.read_from_file = mocker.Mock(return_value=mock_overrides_schema)
416-
425+
417426
mock_pipeline = mocker.Mock()
418427
mock_pipeline.initialize_for_introspection = mocker.Mock()
419428
mock_pipeline.expand_schema = mocker.Mock()
420-
mocker.patch.object(project, 'get_pipeline_by_names', return_value=[mock_pipeline])
421-
429+
mocker.patch.object(project, "get_pipeline_by_names", return_value=[mock_pipeline])
430+
422431
overrides_path = Path("some/overrides.yaml")
423432
result = project.get_pipelines_schema(["test"], overrides_path)
424-
433+
425434
Schema.read_from_file.assert_called_once_with(overrides_path)
426435
mock_base_schema.merge.assert_called_once_with(mock_overrides_schema)
427436
assert_that(result, same_instance(mock_base_schema))
428437

429438

430439
def test_get_pipelines_schema_nonexistent_pipeline_raises_error(project, mocker):
431-
mocker.patch.object(project, 'get_pipeline_by_names', return_value=[])
432-
440+
mocker.patch.object(project, "get_pipeline_by_names", return_value=[])
441+
433442
with pytest.raises(ValueError) as exc_info:
434443
project.get_pipelines_schema(["nonexistent"])
435-
444+
436445
error_message = str(exc_info.value)
437-
assert_that(error_message, equal_to(
438-
"None of the specified pipelines ['nonexistent'] were found. Available pipelines: ['test', 'test2']"
439-
))
446+
assert_that(
447+
error_message,
448+
equal_to(
449+
"None of the specified pipelines ['nonexistent'] were found. Available pipelines: ['test', 'test2']"
450+
),
451+
)
452+
440453

441454
def test_get_pipeline_by_names(project):
442455
pipelines = list(project.get_pipeline_by_names(["test", "test2"]))
443-
456+
444457
assert_that(pipelines, has_length(2))
445458
assert_that([p.name for p in pipelines], contains_inanyorder("test", "test2"))
446459

@@ -452,6 +465,6 @@ def test_get_pipeline_by_names_nonexistent_pipeline(project):
452465

453466
def test_get_pipeline_by_names_mixed_existing_nonexisting(project):
454467
pipelines = list(project.get_pipeline_by_names(["test", "nonexistent", "test2"]))
455-
468+
456469
assert_that(pipelines, has_length(2))
457470
assert_that([p.name for p in pipelines], contains_inanyorder("test", "test2"))

0 commit comments

Comments
 (0)