Skip to content

Fix Python 3.9 compatibility and formatting for lazy-loaded global context - #182

Merged
RyanTheRobothead merged 3 commits into
fix_context_cli_helpfrom
copilot/sub-pr-180
Nov 17, 2025
Merged

Fix Python 3.9 compatibility and formatting for lazy-loaded global context#182
RyanTheRobothead merged 3 commits into
fix_context_cli_helpfrom
copilot/sub-pr-180

Conversation

Copilot AI commented Nov 17, 2025

Copy link
Copy Markdown
Contributor

PR Info

Fixes Python 3.9 backward compatibility issue and formatting violations after implementing lazy-loaded GlobalMadsciContext to prevent --help argument capture.

Changes:

  • Fixed Python 3.9 compatibility: replaced pipe operator (|) with Optional from typing for type unions
  • Added Optional to imports in context.py
  • Updated type hints: MadsciContext | NoneOptional[MadsciContext]
  • Fixed ruff formatting violation: wrapped long assertion line in test_global_context_across_threads
  • Verified all 7 context tests and 97 madsci_common tests pass
  • Confirmed no security issues via CodeQL scan

Developer Checklists

I have:

  • Run Pre-commit and Unit Tests, and ensured that they pass
  • Created or updated documentation relevant to your change
  • Created or updated unit tests relevant to your change

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: LuckierDodge <15006408+LuckierDodge@users.noreply.github.com>

Copilot AI commented Nov 17, 2025

Copy link
Copy Markdown
Contributor Author

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • dl.min.io
    • Triggering command: minio server /data --console-address :9001 (dns block)
  • gitlab.com
    • Triggering command: /usr/lib/git-core/git-remote-https origin REDACTED (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] Modify global context to prevent --help arg capture Fix formatting and verify tests for lazy-loaded global context Nov 17, 2025
@RyanTheRobothead

Copy link
Copy Markdown
Member

@copilot the tests are erroring out due to a 3.9 backcompat issue (use of a pipe operator instead of typing.Union for type hints). Please address this issue.

=========================== short test summary info ============================
ERROR src/madsci_client/tests/test_event_client.py - TypeError: unsupported operand type(s) for |: 'ModelMetaclass' and 'NoneType'
ERROR src/madsci_client/tests/test_experiment_client.py - TypeError: unsupported operand type(s) for |: 'ModelMetaclass' and 'NoneType'
ERROR src/madsci_client/tests/test_workcell_client.py - TypeError: unsupported operand type(s) for |: 'ModelMetaclass' and 'NoneType'
ERROR src/madsci_common/tests/test_context.py - TypeError: unsupported operand type(s) for |: 'ModelMetaclass' and 'NoneType'
ERROR src/madsci_common/tests/test_manager_base.py - TypeError: unsupported operand type(s) for |: 'ModelMetaclass' and 'NoneType'
ERROR src/madsci_data_manager/tests/test_data_client.py - TypeError: unsupported operand type(s) for |: 'ModelMetaclass' and 'NoneType'
ERROR src/madsci_data_manager/tests/test_data_server.py - TypeError: unsupported operand type(s) for |: 'ModelMetaclass' and 'NoneType'
ERROR src/madsci_event_manager/tests/test_event_server.py - TypeError: unsupported operand type(s) for |: 'ModelMetaclass' and 'NoneType'
ERROR src/madsci_event_manager/tests/test_notifications.py - TypeError: unsupported operand type(s) for |: 'ModelMetaclass' and 'NoneType'
ERROR src/madsci_experiment_application/tests/test_experiment_application.py - TypeError: unsupported operand type(s) for |: 'ModelMetaclass' and 'NoneType'
ERROR src/madsci_experiment_manager/tests/test_experiment_server.py - TypeError: unsupported operand type(s) for |: 'ModelMetaclass' and 'NoneType'
ERROR src/madsci_location_manager/tests/test_location_client.py - TypeError: unsupported operand type(s) for |: 'ModelMetaclass' and 'NoneType'
ERROR src/madsci_location_manager/tests/test_location_server.py - TypeError: unsupported operand type(s) for |: 'ModelMetaclass' and 'NoneType'
ERROR src/madsci_node_module/tests - TypeError: unsupported operand type(s) for |: 'ModelMetaclass' and 'NoneType'
ERROR src/madsci_resource_manager/tests/test_resource_client.py - TypeError: unsupported operand type(s) for |: 'ModelMetaclass' and 'NoneType'
ERROR src/madsci_resource_manager/tests/test_resource_interface.py - TypeError: unsupported operand type(s) for |: 'ModelMetaclass' and 'NoneType'
ERROR src/madsci_resource_manager/tests/test_resource_server.py - TypeError: unsupported operand type(s) for |: 'ModelMetaclass' and 'NoneType'
ERROR src/madsci_squid/tests/test_lab_server.py - TypeError: unsupported operand type(s) for |: 'ModelMetaclass' and 'NoneType'
ERROR src/madsci_workcell_manager/tests/test_default_scheduler.py - TypeError: unsupported operand type(s) for |: 'ModelMetaclass' and 'NoneType'
ERROR src/madsci_workcell_manager/tests/test_workcell_actions.py - TypeError: unsupported operand type(s) for |: 'ModelMetaclass' and 'NoneType'
ERROR src/madsci_workcell_manager/tests/test_workcell_engine.py - TypeError: unsupported operand type(s) for |: 'ModelMetaclass' and 'NoneType'
ERROR src/madsci_workcell_manager/tests/test_workcell_server.py - TypeError: unsupported operand type(s) for |: 'ModelMetaclass' and 'NoneType'
ERROR src/madsci_workcell_manager/tests/test_workcell_utils.py - TypeError: unsupported operand type(s) for |: 'ModelMetaclass' and 'NoneType'
!!!!!!!!!!!!!!!!!!! Interrupted: 23 errors during collection !!!!!!!!!!!!!!!!!!!
============================== 23 errors in 5.90s ==============================

Co-authored-by: LuckierDodge <15006408+LuckierDodge@users.noreply.github.com>

Copilot AI commented Nov 17, 2025

Copy link
Copy Markdown
Contributor Author

@copilot the tests are erroring out due to a 3.9 backcompat issue (use of a pipe operator instead of typing.Union for type hints). Please address this issue.

=========================== short te...

Fixed the Python 3.9 compatibility issue (commit 1ee2dfd). Replaced the pipe operator (|) for type unions with Optional from typing, which is compatible with Python 3.9. All context tests and madsci_common tests now pass.

Copilot AI changed the title Fix formatting and verify tests for lazy-loaded global context Fix Python 3.9 compatibility and formatting for lazy-loaded global context Nov 17, 2025
@github-actions

Copy link
Copy Markdown

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  src/madsci_common/madsci/common
  context.py
Project Total  

This report was generated by python-coverage-comment-action

@RyanTheRobothead
RyanTheRobothead marked this pull request as ready for review November 17, 2025 20:41
@RyanTheRobothead
RyanTheRobothead merged commit 5029e08 into fix_context_cli_help Nov 17, 2025
6 checks passed
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