Skip to content
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

python 3.13 and typing.io namespace #11

Open
vredesbyyrd opened this issue Dec 25, 2024 · 0 comments
Open

python 3.13 and typing.io namespace #11

vredesbyyrd opened this issue Dec 25, 2024 · 0 comments

Comments

@vredesbyyrd
Copy link

Just a note for the maintainer or anyone who may run into this, In Python 3.13 the typing.io namespace was removed. You need to import the types directly from the typing module. I'm no python expert so there may be a better approach, but here are the changes I made to colr.py to get things working with python 3.13.

--- colr.py.orig	        2024-12-25 16:26:24.188215303 -0600
+++ colr.py	        2024-12-25 16:43:58.837710220 -0600
@@ -48,8 +48,10 @@
     Tuple,
     Union,
     cast,
+    TextIO, # MORPH 12/25/2024 - import directly from typing module
 )
-from typing.io import IO
+#MORPH 12/25/2024 - In Python 3.13, the typing.io namespace
+#has been removed. You can import the types directly from the typing module

 from .base import (
     ChainedBase,
@@ -158,7 +160,7 @@

 def auto_disable(
         enabled: Optional[bool] = True,
-        fds: Optional[Sequence[IO]] = (sys.stdout, sys.stderr)) -> None:
+        fds: Optional[Sequence[TextIO]] = (sys.stdout, sys.stderr)) -> None: #MORPH 12/25/2024
     """ Automatically decide whether to disable color codes if stdout or
         stderr are not ttys.

@@ -173,7 +175,7 @@
     if enabled:
         allttys = all(
             getattr(f, 'isatty', lambda: False)()
-            for f in cast(Sequence[IO], fds)
+            for f in cast(Sequence[TextIO], fds) #MORPH 12/25/2024
         )
         if not allttys:
             disable()
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

No branches or pull requests

1 participant