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

Remove ansi2html. #2721

Merged
merged 5 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ This project adheres to [Semantic Versioning](https://semver.org/).

## Changed
- [#2652](https://github.com/plotly/dash/pull/2652) dcc.Clipboard supports htm_content and triggers a copy to clipboard when n_clicks are changed
- [#2721](https://github.com/plotly/dash/pull/2721) Remove ansi2html, fixes [#2613](https://github.com/plotly/dash/issues/2713)

## [2.14.2] - 2023-11-27

Expand Down
28 changes: 5 additions & 23 deletions dash/_jupyter.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import os
import queue
import uuid
import re
import sys
import threading
import time
Expand All @@ -22,7 +21,6 @@
from IPython.core.display import HTML
from IPython.core.ultratb import FormattedTB
from retrying import retry
from ansi2html import Ansi2HTMLConverter
from ipykernel.comm import Comm
import nest_asyncio

Expand Down Expand Up @@ -450,13 +448,12 @@ def _wrap_errors(error):
original_formatargvalues = inspect.formatargvalues
inspect.formatargvalues = _custom_formatargvalues
try:
# Use IPython traceback formatting to build colored ANSI traceback
# string
# Use IPython traceback formatting to build the traceback string.
ostream = io.StringIO()
ipytb = FormattedTB(
tb_offset=skip,
mode="Verbose",
color_scheme="Linux",
color_scheme="NoColor",
include_vars=True,
ostream=ostream,
)
Expand All @@ -465,27 +462,12 @@ def _wrap_errors(error):
# Restore formatargvalues
inspect.formatargvalues = original_formatargvalues

# Print colored ANSI representation if requested
ansi_stacktrace = ostream.getvalue()
stacktrace = ostream.getvalue()

if self.inline_exceptions:
print(ansi_stacktrace)
print(stacktrace)

# Use ansi2html to convert the colored ANSI string to HTML
conv = Ansi2HTMLConverter(scheme="ansi2html", dark_bg=False)
html_str = conv.convert(ansi_stacktrace)

# Set width to fit 75-character wide stack trace and font to a size the
# won't require a horizontal scroll bar
html_str = html_str.replace(
"<html>", '<html style="width: 75ch; font-size: 0.86em">'
)

# Remove explicit background color so Dash dev-tools can set background
# color
html_str = re.sub("background-color:[^;]+;", "", html_str)

return html_str, 500
return stacktrace, 500

@property
def active(self):
Expand Down
2 changes: 1 addition & 1 deletion requires-ci.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ flake8==3.9.2
flaky==3.7.0
flask-talisman==1.0.0
isort==4.3.21;python_version<"3.7"
mimesis
mimesis<=11.1.0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NBD since this is only in requires-ci, but why is this lock needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The latest version introduced a union type like str | int and that is only supported in recent python versions.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK yeah weird:

To work with Mimesis on Python versions 3.8 and 3.9, the final compatible version is Mimesis 11.1.0. Install this specific version to ensure compatibility.

but even v12.1.0 says

Requires: Python >=3.8, <4.0

Wonder why they didn't just bake that first statement into the python_requires 🤔

mock==4.0.3
numpy<=1.25.2
orjson==3.5.4;python_version<"3.7"
Expand Down
1 change: 0 additions & 1 deletion requires-install.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@ contextvars==2.4;python_version<"3.7"
typing_extensions>=4.1.1
requests
retrying
ansi2html
nest-asyncio
setuptools