Skip to content

Pyright and ruff checking for Database Server #399

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

Merged
merged 8 commits into from
Oct 18, 2024

Conversation

LowriJenkins
Copy link
Contributor

@LowriJenkins LowriJenkins commented Oct 18, 2024

Description of work

Performed ruff and pyright checks on the database server

To test

Which ticket does this PR fix?

Relies on:

https://github.com/ISISComputingGroup/genie_python/pull/442

@Tom-Willemsen
Copy link
Contributor

Unfortunately looks like unit tests are broken by this:

======================================================================

ERROR [0.054s]: DatabaseServer.test_modules (unittest.loader._FailedTest.DatabaseServer.test_modules)

----------------------------------------------------------------------

ImportError: Failed to import test module: DatabaseServer.test_modules

Traceback (most recent call last):

  File "\\isis.cclrc.ac.uk\inst$\Kits$\CompGroup\ICP\genie_python_3\BUILD-3008\Python\Lib\unittest\loader.py", line 452, in _find_test_path

    package = self._get_module_from_name(name)

              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "\\isis.cclrc.ac.uk\inst$\Kits$\CompGroup\ICP\genie_python_3\BUILD-3008\Python\Lib\unittest\loader.py", line 362, in _get_module_from_name

    __import__(name)

  File "E:\Jenkins\workspace\inst_servers_pr_pipeline_PR-399\DatabaseServer\test_modules\__init__.py", line 26, in <module>

    def load_tests(loader: TestLoader, standard_tests: TestSuite, pattern: str) -> TestSuite:

                           ^^^^^^^^^^

NameError: name 'TestLoader' is not defined



----------------------------------------------------------------------

You may need to guard some imports with if TYPE_CHECKING and stringify them

Comment on lines +46 to +52
def _is_list_of_str_list(val: list[list]) -> TypeGuard[list[list[str]]]:
sublist_vals = [_is_list_of_str(sublist) for sublist in val]
return all(sublist_vals)


def _is_list_of_str(val: list) -> TypeGuard[list[str]]:
return all(isinstance(val, str) for x in val)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@LowriJenkins
Copy link
Contributor Author

should be fixed now I think?

Copy link
Contributor

@Tom-Willemsen Tom-Willemsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Jenkins unhappiness should be solved by your g_p PR.

@Tom-Willemsen Tom-Willemsen merged commit c6d48ab into master Oct 18, 2024
2 of 3 checks passed
@Tom-Willemsen Tom-Willemsen deleted the Ticket8527_Database_server_Type_checking branch October 18, 2024 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants