From 661de4a30dda64b937c31284df36b82bbcf4e4b8 Mon Sep 17 00:00:00 2001 From: Sajith Sasidharan Date: Fri, 19 Apr 2024 14:29:09 -0500 Subject: [PATCH 1/5] Update black --- .github/workflows/checks.yml | 2 +- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 861d3cba..96845349 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -43,7 +43,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install black==23.* isort==5.* + python -m pip install black==24.* isort==5.* - name: Run "black --check" run: | diff --git a/pyproject.toml b/pyproject.toml index e6f95da5..ded2bb99 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -49,7 +49,7 @@ doc = [ "furo" ] test = [ - "black==23.*", + "black==24.*", "isort==5.*", "tox==4.*", "pytest", From 320d2aa551dd1bb98c5768c8e6b79652b1e52a15 Mon Sep 17 00:00:00 2001 From: Sajith Sasidharan Date: Fri, 19 Apr 2024 14:31:21 -0500 Subject: [PATCH 2/5] Remove unsupported black config key black 24.4.0 says: > Invalid config keys detected: 'src_paths' (in > /home/sajith/projects/fabric-testbed/fabrictestbed-extensions/pyproject.toml) --- pyproject.toml | 3 --- 1 file changed, 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index ded2bb99..4f45e1f6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -60,9 +60,6 @@ test = [ branch = true omit = ["fabrictestbed_extensions/tests/*"] -[tool.black] -src_paths = ["fabrictestbed_extensions", "docs/source/conf.py", "tests"] - [tool.isort] profile = "black" src_paths = ["fabrictestbed_extensions", "docs/source/conf.py", "tests"] From 6663a4341aa690b713fc3ee4c0735585ae78d7c6 Mon Sep 17 00:00:00 2001 From: Sajith Sasidharan Date: Fri, 19 Apr 2024 14:32:32 -0500 Subject: [PATCH 3/5] Re-run black --- .../editors/geo_topology_editor.py | 12 ++++++------ fabrictestbed_extensions/fablib/slice.py | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/fabrictestbed_extensions/editors/geo_topology_editor.py b/fabrictestbed_extensions/editors/geo_topology_editor.py index 8166adfb..85179f93 100644 --- a/fabrictestbed_extensions/editors/geo_topology_editor.py +++ b/fabrictestbed_extensions/editors/geo_topology_editor.py @@ -1460,9 +1460,9 @@ def load_node(self, node_name): self.current_node = node self.dashboards["node_dashboard"]["node_name_widget"].value = node_name - self.dashboards["node_dashboard"][ - "site_name_widget" - ].value = node.get_property(pname="site") + self.dashboards["node_dashboard"]["site_name_widget"].value = ( + node.get_property(pname="site") + ) self.dashboards["node_dashboard"]["core_slider"].value = int( self.get_capacity_value(node, "core") ) @@ -1475,9 +1475,9 @@ def load_node(self, node_name): self.dashboards["node_dashboard"]["image_widget"].value = node.get_property( pname="image_ref" ) - self.dashboards["node_dashboard"][ - "image_type_widget" - ].value = node.get_property(pname="image_type") + self.dashboards["node_dashboard"]["image_type_widget"].value = ( + node.get_property(pname="image_type") + ) # TODO: LOAD Components diff --git a/fabrictestbed_extensions/fablib/slice.py b/fabrictestbed_extensions/fablib/slice.py index 7ccef1af..42134c9c 100644 --- a/fabrictestbed_extensions/fablib/slice.py +++ b/fabrictestbed_extensions/fablib/slice.py @@ -1200,9 +1200,9 @@ def get_notices(self) -> Dict[str, str]: notices[node.get_reservation_id()] = node.get_error_message() for network_service in self.get_network_services(): - notices[ - network_service.get_reservation_id() - ] = network_service.get_error_message() + notices[network_service.get_reservation_id()] = ( + network_service.get_error_message() + ) for component in self.get_components(): notices[component.get_reservation_id()] = component.get_error_message() From 557d4ba1c67dd4241c57b0277ecd2b71eca372ef Mon Sep 17 00:00:00 2001 From: Sajith Sasidharan Date: Fri, 19 Apr 2024 14:36:05 -0500 Subject: [PATCH 4/5] Add a tox environment for formatting code --- tox.ini | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tox.ini b/tox.ini index c3dda59e..6ee822d9 100644 --- a/tox.ini +++ b/tox.ini @@ -28,3 +28,15 @@ deps = commands = sphinx-build -W -b html {toxinidir}/docs/source/ {toxinidir}/docs/build/html + +[testenv:format] +# An environment for formatting code. +deps = + black==24.* + isort==5.* + +skip_install = True + +commands = + black fabrictestbed_extensions tests + isort fabrictestbed_extensions tests From 5b5058c42cc5524f3a4191084cefc39eba48651f Mon Sep 17 00:00:00 2001 From: Sajith Sasidharan Date: Fri, 19 Apr 2024 14:53:56 -0500 Subject: [PATCH 5/5] Mention `tox -e format` in contribution notes --- CONTRIBUTING.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2d531678..b5bf796b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -66,6 +66,13 @@ $ pip install -e .[test] $ pytest -s tests/integration/test_hello_fabric.py ``` +If you want to format code with [black] and [isort]: + +``` +$ tox -e format +``` + + ## Documenting FABlib FABlib uses Sphinx to generate API documentation from Python