Repository: magmax/python-readchar (language: python)

Issue:
`readchar.key` direct uses fail
code like this failes with the new version:

```python
import readchar

print(readchar.key.UP)
```
> :x: AttributeError: module 'readchar' has no attribute 'key'


This needs to be fixed as it is required for backwards compatability


Discussion / hints:

Fix patch:
diff --git a/readchar/__init__.py b/readchar/__init__.py
index 64817a1..8ba31da 100644
--- a/readchar/__init__.py
+++ b/readchar/__init__.py
@@ -12,7 +12,9 @@
     or platform.startswith("freebsd")
 ):
     from ._posix_read import readchar, readkey
+    from . import _posix_key as key
 elif platform in ("win32", "cygwin"):
     from ._win_read import readchar, readkey
+    from . import _win_key as key
 else:
     raise NotImplementedError(f"The platform {platform} is not supported yet")
diff --git a/readchar/key.py b/readchar/key.py
index a73163a..0e83a2a 100644
--- a/readchar/key.py
+++ b/readchar/key.py
@@ -1,4 +1,6 @@
 # flake8: noqa E401,E403
+# this file exists only for backwards compatability
+# it allow the use of `import readchar.key`
 
 from . import platform
 


Test patch:
diff --git a/tests/posix/test_import.py b/tests/posix/test_import.py
index 4c858e5..0dde25d 100644
--- a/tests/posix/test_import.py
+++ b/tests/posix/test_import.py
@@ -11,6 +11,5 @@ def test_readkeyImport():
 
 def test_keyImport():
     a = {k: v for k, v in vars(readchar.key).items() if not k.startswith("__")}
-    del a["platform"]
     b = {k: v for k, v in vars(readchar._posix_key).items() if not k.startswith("__")}
     assert a == b
diff --git a/tests/windows/test_import.py b/tests/windows/test_import.py
index 2d762d3..4b52d33 100644
--- a/tests/windows/test_import.py
+++ b/tests/windows/test_import.py
@@ -11,6 +11,5 @@ def test_readkeyImport():
 
 def test_keyImport():
     a = {k: v for k, v in vars(readchar.key).items() if not k.startswith("__")}
-    del a["platform"]
     b = {k: v for k, v in vars(readchar._win_key).items() if not k.startswith("__")}
     assert a == b