Skip to content

Commit

Permalink
Please pyright
Browse files Browse the repository at this point in the history
`pyright` was complaining about the `exec_diagnose`. That issue occurs because
based on the Barman module version that is installed in the virtual
environemnt, the signature of that method would have either 2 or 4 parameters.

We had 2 options to handle that issue:

* Add `pyright: ignore` directives to the source code where `exec_diagnose` is
  called; or
* Change the implementation so instead of relying on `AttributeError`
  exception, it would handle the version for the Barman module.

We chose the first option for now, so we unblock the release. The code with
`AttributeError` exception has already been tested. If we were to go with the
second option now, that would require changing the code, changing the unit tests
and performing more tests, thus dealying the release.

Signed-off-by: Israel Barth Rubio <[email protected]>
  • Loading branch information
barthisrael authored and gonzalemario committed Jun 28, 2024
1 parent e83ae2f commit d7db6aa
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions pg_backup_api/pg_backup_api/logic/utility_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,20 @@ def diagnose() -> 'Response':
for model in available_models: # pyright: ignore
model_dict[model] = barman.__config__.get_model(model)

barman_diagnose.exec_diagnose(server_dict,
model_dict,
errors_list,
show_config_source=False)
barman_diagnose.exec_diagnose(
server_dict,
model_dict,
errors_list,
show_config_source=False,
) # pyright: ignore [reportCallIssue]
# An attribute error is thown when calling `model_names()` if using Barman
# older than 3.10, in which case models are not yet implemented, so we fall
# back to the old signature of diagnose command.
except AttributeError:
barman_diagnose.exec_diagnose(server_dict, errors_list)
barman_diagnose.exec_diagnose(
server_dict,
errors_list,
) # pyright: ignore [reportCallIssue]

# new outputs are appended, so grab the last one
stored_output = json.loads(output._writer.json_output["_INFO"][-1])
Expand Down

0 comments on commit d7db6aa

Please sign in to comment.