Skip to content

Commit b701cdb

Browse files
committed
Make colorama optional on Python 3.10
1 parent b1efbaf commit b701cdb

File tree

8 files changed

+15
-9
lines changed

8 files changed

+15
-9
lines changed

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ Spun out from `repo_helper <https://github.com/domdfcoding/repo_helper>`_. Needs
110110
:target: https://github.com/domdfcoding/consolekit/commit/master
111111
:alt: GitHub last commit
112112

113-
.. |maintained| image:: https://img.shields.io/maintenance/yes/2020
113+
.. |maintained| image:: https://img.shields.io/maintenance/yes/2021
114114
:alt: Maintenance
115115

116116
.. |pypi-downloads| image:: https://img.shields.io/pypi/dm/consolekit

__pkginfo__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
]
2424

2525
__copyright__ = """
26-
2020 Dominic Davis-Foster <[email protected]>
26+
2020-2021 Dominic Davis-Foster <[email protected]>
2727
"""
2828

2929
__version__ = "0.7.0"

consolekit/terminal_colours.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@
7676

7777
# 3rd party
7878
import click
79-
import colorama # type: ignore
8079
from typing_extensions import Final
8180

8281
__all__ = [
@@ -100,7 +99,12 @@
10099
"strip_ansi",
101100
]
102101

103-
colorama.init()
102+
103+
try:
104+
import colorama # type: ignore
105+
colorama.init()
106+
except ImportError:
107+
pass
104108

105109
CSI: Final[str] = "\u001b["
106110
OSC: Final[str] = "\u001b]"

doc-source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
project = "consolekit"
2727
slug = re.sub(r'\W+', '-', project.lower())
2828
release = version = __version__
29-
copyright = "2020 Dominic Davis-Foster" # pylint: disable=redefined-builtin
29+
copyright = "2020-2021 Dominic Davis-Foster" # pylint: disable=redefined-builtin
3030
language = "en"
3131
package_root = "consolekit"
3232

doc-source/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ consolekit
110110
:last-commit:
111111
:alt: GitHub last commit
112112

113-
.. |maintained| maintained-shield:: 2020
113+
.. |maintained| maintained-shield:: 2021
114114
:alt: Maintenance
115115

116116
.. |pypi-downloads| pypi-shield::

repo_helper.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Configuration for 'repo_helper' (https://github.com/domdfcoding/repo_helper)
22
---
33
modname: 'consolekit'
4-
copyright_years: '2020'
4+
copyright_years: '2020-2021'
55
author: 'Dominic Davis-Foster'
66
77
username: 'domdfcoding'

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
click>=7.1.2
2-
colorama>=0.4.3
2+
colorama>=0.4.3; python_version < "3.10"
33
domdf-python-tools>=1.3.0
44
typing-extensions>=3.7.4.3

tests/test_terminal_colours_colorama.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,16 @@
3232

3333
# 3rd party
3434
import pytest
35-
from colorama.ansitowin32 import AnsiToWin32 # type: ignore
3635

3736
# this package
3837
from consolekit.terminal_colours import Back, Fore, Style
3938

4039
stdout_orig = sys.stdout
4140
stderr_orig = sys.stderr
4241

42+
colorama = pytest.importorskip("colorama")
43+
AnsiToWin32 = colorama.ansitowin32.AnsiToWin32
44+
4345

4446
def setup_module():
4547
# sanity check: stdout should be a file or StringIO object.

0 commit comments

Comments
 (0)