<#490 Fix Python 3.14 compatibility issues> Pull r...
# flyte-github
a
#490 Fix Python 3.14 compatibility issues Pull request opened by katrogan This commit resolves two Python 3.14-specific issues that prevented the flyte CLI from working: 1. Import deadlock in syncify module: The background thread created during module initialization was importing flyte.errors while the main thread held the import lock, causing a deadlock. Fixed by wrapping the exception handler to delay the import until needed. 2. Double registration of Union type: In Python 3.14, types.UnionType and typing.Union are the same object, causing a double-registration error. Fixed by conditionally registering UnionType only if it differs from typing.Union. Both fixes maintain backward compatibility with Python 3.10-3.13. Tested by making sure I could successfully launch an example Before:
uv pip install --pre flyte
flyte --version
Copy code
Traceback (most recent call last):
Exception in thread flyte_syncify:
  File "/Users/katrina/src/flyte/flyte-sdk/.venv/bin/flyte", line 4, in <module>
    from flyte.cli.main import main
  File "/Users/katrina/src/flyte/flyte-sdk/.venv/lib/python3.14/site-packages/flyte/__init__.py", line 13, in <module>
    from ._deploy import build_images, deploy
  File "/Users/katrina/src/flyte/flyte-sdk/.venv/lib/python3.14/site-packages/flyte/_deploy.py", line 16, in <module>
    from ._initialize import ensure_client, get_client, get_init_config, requires_initialization
  File "/Users/katrina/src/flyte/flyte-sdk/.venv/lib/python3.14/site-packages/flyte/_initialize.py", line 11, in <module>
    from flyte.errors import InitializationError
  File "<frozen importlib._bootstrap>", line 1368, in _find_and_load
  File "<frozen importlib._bootstrap>", line 421, in __enter__
  File "<frozen importlib._bootstrap>", line 346, in acquire
_frozen_importlib._DeadlockError: deadlock detected by _ModuleLock('flyte.errors') at 4341857360
Traceback (most recent call last):
  File "/Users/katrina/.local/share/uv/python/cpython-3.14.2-macos-aarch64-none/lib/python3.14/threading.py", line 1082, in _bootstrap_inner
    self._context.run(self.run)
    ~~~~~~~~~~~~~~~~~^^^^^^^^^^
  File "/Users/katrina/.local/share/uv/python/cpython-3.14.2-macos-aarch64-none/lib/python3.14/threading.py", line 1024, in run
    self._target(*self._args, **self._kwargs)
    ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/katrina/src/flyte/flyte-sdk/.venv/lib/python3.14/site-packages/flyte/syncify/_api.py", line 67, in _run
    import flyte.errors
  File "<frozen importlib._bootstrap>", line 1371, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1348, in _find_and_load_unlocked
KeyError: 'flyte'
After:
Copy code
uv pip install -e .

flyte --version       
Flyte SDK version: 2.0.0b43.dev2+gc49fe8142
🤖 Generated with Claude Code flyteorg/flyte-sdk