diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 00200fe5..053d1bf7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,7 +3,7 @@ repos: # Syntax validation and some basic sanity checks - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 # Released 2023-10-09 + rev: v4.6.0 # Released 2024-04-06 # rev input based on version tag format in repo (e.g. with or without 'v') hooks: - id: check-added-large-files @@ -26,15 +26,22 @@ repos: # Format the pyproject.toml file - repo: https://github.com/tox-dev/pyproject-fmt - rev: 1.7.0 # Released 2024-01-22 + rev: 1.8.0 # Released 2024-04-17 | Latest version that retains ability to group project keys under sub-tables hooks: - id: pyproject-fmt name: Formatting the pyproject.toml file additional_dependencies: ["tox>=4.9"] + # args: [ + # "--check", + # "--keep-full-version", + # "--max-supported-python", "3.11", + # "--indent", "8", + # "./pyproject.toml", + # ] # Automatic source code formatting - repo: https://github.com/psf/black - rev: 24.3.0 # Released 2024-03-15 + rev: 24.8.0 # Released 2024-08-02 hooks: - id: black name: Formatting Python scripts according to Black @@ -69,20 +76,20 @@ repos: # Linting - repo: https://github.com/PyCQA/flake8 # Release history: https://flake8.pycqa.org/en/latest/release-notes/index.html - rev: 7.0.0 # Released 2024-01-05 + rev: 7.1.1 # Released 2024-08-04 hooks: - id: flake8 name: Running Flake8 linter on Python files additional_dependencies: [ - # Added Flake8-pyproject plugin for .toml compatibility + # Added Flake8-pyproject plugin for .toml compatibility | URL: https://github.com/john-hen/Flake8-pyproject "Flake8-pyproject==1.2.3", # Released 2023-03-21 # flake8-comprehensions URL: https://github.com/adamchainz/flake8-comprehensions - "flake8-comprehensions==3.14.0", # Released 2023-07-10 + "flake8-comprehensions==3.15.0", # Released 2024-06-29 ] # Type checking - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.9.0 # Released 2024-03-09 + rev: v1.11.1 # Released 2024-07-31 hooks: - id: mypy name: Checking types in Python scripts using MyPy diff --git a/pyproject.toml b/pyproject.toml index 0f4986e2..e210b2e9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,168 +1,166 @@ -[build-system] -build-backend = "setuptools.build_meta" -requires = [ - "setuptools >= 40.6.0", - "wheel", -] - -[project] -name = "murfey" -version = "0.12.2" -description = "Client-Server architecture hauling Cryo-EM data" -readme = "README.md" -keywords = [ - "", -] -license = {file = "LICENSE"} -maintainers = [] -authors = [] -requires-python = ">=3.9" -classifiers = [ - "Development Status :: 3 - Alpha", - "Environment :: Console", - "Intended Audience :: Science/Research", - "License :: OSI Approved :: BSD License", - "Operating System :: OS Independent", - "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", -] -dependencies = [ - "defusedxml", # For safely parsing XML files - "pydantic<2", # Locked to <2 by zocalo - "requests", - "rich", - "werkzeug", -] -[project.optional-dependencies] -cicd = [ - "pytest-cov", # Used by Azure Pipelines for PyTest coverage reports -] -client = [ - "procrunner", - "textual==0.42.0", - "websocket-client", - "xmltodict", -] -developer = [ - "bump2version", # Version control - "ipykernel", # Enable interactive coding with VS Code and Jupyter Notebook - "pre-commit", # Formatting, linting, type checking, etc. - "pytest", # Test code functionality -] -server = [ - # "matplotlib", # For visual statistical analysis of images - "cryptography", - "fastapi[standard]", - "ispyb", # Responsible for setting requirements for SQLAlchemy and mysql-connector-python; v10.0.0: sqlalchemy <2, mysql-connector-python >=8.0.32 - "jinja2", - "mrcfile", - "numpy", - "packaging", - "passlib", - "pillow", - "prometheus_client", - "python-jose[cryptography]", - "sqlmodel", - "stomp-py<=8.1.0", # 8.1.1 (released 2024-04-06) doesn't work with our project - "uvicorn[standard]", - "zocalo", -] -[project.urls] -Bug-Tracker = "https://github.com/DiamondLightSource/python-murfey/issues" -Documentation = "https://github.com/DiamondLightSource/python-murfey" -GitHub = "https://github.com/DiamondLightSource/python-murfey" -[project.scripts] -murfey = "murfey.client:run" -"murfey.add_user" = "murfey.cli.add_user:run" -"murfey.create_db" = "murfey.cli.create_db:run" -"murfey.db_sql" = "murfey.cli.murfey_db_sql:run" -"murfey.decrypt_password" = "murfey.cli.decrypt_db_password:run" -"murfey.generate_key" = "murfey.cli.generate_crypto_key:run" -"murfey.generate_password" = "murfey.cli.generate_db_password:run" -"murfey.server" = "murfey.server:run" -"murfey.sessions" = "murfey.cli.db_sessions:run" -"murfey.simulate" = "murfey.cli.dummy:run" -"murfey.spa_inject" = "murfey.cli.inject_spa_processing:run" -"murfey.spa_ispyb_entries" = "murfey.cli.spa_ispyb_messages:run" -"murfey.transfer" = "murfey.cli.transfer:run" -[project.entry-points."murfey.workflows"] -"lif_to_stack" = "murfey.workflows.lif_to_stack:zocalo_cluster_request" -"tiff_to_stack" = "murfey.workflows.tiff_to_stack:zocalo_cluster_request" - -[tool.setuptools] -package-dir = {"" = "src"} -include-package-data = true -zip-safe = false - -[tool.setuptools.package-data] -"murfey.client.tui" = ["*.css"] - -[tool.setuptools.packages.find] -where = ["src", "tests"] - -[tool.isort] -profile = "black" - -[tool.flake8] -# Flake8-pyproject allows TOML file settings to be read into Flake8 -# URL: https://pypi.org/project/Flake8-pyproject/ -select = [ - "C4", - "E401", - "E711", - "E712", - "E713", - "E714", - "E721", - "E722", - "E901", - "F401", - "F402", - "F403", - "F405", - "F541", - "F631", - "F632", - "F633", - "F811", - "F812", - "F821", - "F822", - "F841", - "F901", - "W191", - "W291", - "W292", - "W293", - "W602", - "W603", - "W604", - "W605", - "W606", -] -ignore = [ - "E203", - "E266", - "E501", - "W503", -] -max-line-length = "88" - -[tool.pyproject-fmt] -inputs = "pyproject.toml" -check = false -indent = 4 -keep_full_version = true -max-supported-python = "3.12" - -[tool.pytest.ini_options] -addopts = "-ra" - -[tool.mypy] -disable_error_code = [ - "annotation-unchecked", # Notification that the bodies of untyped functions aren't checked. Not critical - "import-untyped", # Error for missing library stubs. Not critical -] +[build-system] +build-backend = "setuptools.build_meta" +requires = [ + "setuptools >= 40.6.0", + "wheel", +] + +[project] +name = "murfey" +version = "0.12.2" +description = "Client-Server architecture hauling Cryo-EM data" +readme = "README.md" +keywords = [ + "", +] +license = {file = "LICENSE"} +maintainers = [] +authors = [] +requires-python = ">=3.9" +classifiers = [ + "Development Status :: 3 - Alpha", + "Environment :: Console", + "Intended Audience :: Science/Research", + "License :: OSI Approved :: BSD License", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", +] +dependencies = [ + "defusedxml", # Used for safely extracting XML elements + "importlib-metadata", # Needed in both client and server for Python >3.9 + "pydantic<2", # Fixed to <2 by zocalo in [server] dependencies + "requests", + "rich", + "werkzeug", +] +[project.optional-dependencies] +cicd = [ + "pytest-cov", # Used by Azure Pipelines for PyTest coverage reports +] +client = [ + "procrunner", + "textual", # ==0.42.0", # importlib-metadata a former dependency of theirs + "websocket-client", + "xmltodict", +] +developer = [ + "bump2version", # Version control + "ipykernel", # Enable interactive coding with VS Code and Jupyter Notebook + "pre-commit", # Formatting, linting, type checking, etc. + "pytest", # Test code functionality +] +server = [ + "cryptography", + "fastapi[standard]", + "ispyb", # Responsible for setting requirements for SQLAlchemy and mysql-connector-python; v10.0.0: sqlalchemy <2, mysql-connector-python >=8.0.32 + "jinja2", + "mrcfile", + "numpy<2", # Locked numpy to <2 while other dependencies catch up + "packaging", + "passlib", + "pillow", + "prometheus_client", + "python-jose[cryptography]", + "sqlalchemy[postgresql]<2", # Installs psycopg2 dependency + "sqlmodel", + "stomp-py", # <=8.1.0", # 8.1.1 (released 2024-04-06) doesn't work with our project # 8.1.2 seems ok + "uvicorn[standard]", + "zocalo", +] +[project.urls] +Bug-Tracker = "https://github.com/DiamondLightSource/python-murfey/issues" +Documentation = "https://github.com/DiamondLightSource/python-murfey" +GitHub = "https://github.com/DiamondLightSource/python-murfey" +[project.scripts] +murfey = "murfey.client:run" +"murfey.add_user" = "murfey.cli.add_user:run" +"murfey.create_db" = "murfey.cli.create_db:run" +"murfey.db_sql" = "murfey.cli.murfey_db_sql:run" +"murfey.decrypt_password" = "murfey.cli.decrypt_db_password:run" +"murfey.generate_key" = "murfey.cli.generate_crypto_key:run" +"murfey.generate_password" = "murfey.cli.generate_db_password:run" +"murfey.server" = "murfey.server:run" +"murfey.sessions" = "murfey.cli.db_sessions:run" +"murfey.simulate" = "murfey.cli.dummy:run" +"murfey.spa_inject" = "murfey.cli.inject_spa_processing:run" +"murfey.spa_ispyb_entries" = "murfey.cli.spa_ispyb_messages:run" +"murfey.transfer" = "murfey.cli.transfer:run" +[project.entry-points."murfey.workflows"] +"lif_to_stack" = "murfey.workflows.lif_to_stack:zocalo_cluster_request" +"tiff_to_stack" = "murfey.workflows.tiff_to_stack:zocalo_cluster_request" + +[tool.setuptools] +package-dir = {"" = "src"} +include-package-data = true +zip-safe = false + +[tool.setuptools.package-data] +"murfey.client.tui" = ["*.css"] + +[tool.setuptools.packages.find] +where = ["src", "tests"] + +[tool.isort] +profile = "black" + +[tool.flake8] +# Flake8-pyproject allows TOML file settings to be read into Flake8 +# URL: https://pypi.org/project/Flake8-pyproject/ +select = [ + "C4", + "E401", + "E711", + "E712", + "E713", + "E714", + "E721", + "E722", + "E901", + "F401", + "F402", + "F403", + "F405", + "F541", + "F631", + "F632", + "F633", + "F811", + "F812", + "F821", + "F822", + "F841", + "F901", + "W191", + "W291", + "W292", + "W293", + "W602", + "W603", + "W604", + "W605", + "W606", +] +ignore = [ + "E203", + "E266", + "E501", + "W503", +] +max-line-length = "88" + +[tool.pyproject-fmt] +indent = 4 +keep_full_version = true +max_supported_python = "3.11" + +[tool.pytest.ini_options] +addopts = "-ra" + +[tool.mypy] +disable_error_code = [ + "annotation-unchecked", # Notification that the bodies of untyped functions aren't checked. Not critical + "import-untyped", # Error for missing library stubs. Not critical +] diff --git a/src/murfey/server/__init__.py b/src/murfey/server/__init__.py index 7b2431ea..cac38616 100644 --- a/src/murfey/server/__init__.py +++ b/src/murfey/server/__init__.py @@ -81,8 +81,8 @@ class ExtendedRecord(NamedTuple): - record: Base - record_params: List[Base] + record: Base # type: ignore + record_params: List[Base] # type: ignore class JobIDs(NamedTuple): @@ -2908,7 +2908,7 @@ def _register(record, header: dict, **kwargs): @_register.register # type: ignore -def _(record: Base, header: dict, **kwargs): +def _(record: Base, header: dict, **kwargs): # type: ignore if not _transport_object: logger.error( f"No transport object found when processing record {record}. Message header: {header}" diff --git a/src/murfey/server/murfey_db.py b/src/murfey/server/murfey_db.py index cafcfaf9..6aaa03fd 100644 --- a/src/murfey/server/murfey_db.py +++ b/src/murfey/server/murfey_db.py @@ -22,7 +22,7 @@ def url(machine_config: MachineConfig | None = None) -> str: def get_murfey_db_session( machine_config: MachineConfig | None = None, -) -> Session: +) -> Session: # type: ignore _url = url(machine_config) if machine_config and not machine_config.sqlalchemy_pooling: engine = create_engine(_url, poolclass=NullPool)