From 4b78978a33a4a601b474ab9cacb1b53c3077cf8c Mon Sep 17 00:00:00 2001 From: John Lyu Date: Thu, 24 Oct 2024 13:49:15 +0800 Subject: [PATCH] lint --- dataframe_image/__init__.py | 2 ++ dataframe_image/_browser_pdf.py | 12 +++++------- dataframe_image/_bundler.py | 2 -- dataframe_image/_convert.py | 4 ---- dataframe_image/_latex_pdf.py | 2 +- dataframe_image/_preprocessors.py | 1 - dataframe_image/converter/__init__.py | 2 +- dataframe_image/converter/browser/__init__.py | 8 ++++++++ dataframe_image/converter/browser/base.py | 2 -- .../converter/browser/playwright_converter.py | 2 -- .../converter/browser/selenium_converter.py | 1 - dataframe_image/converter/matplotlib_table.py | 7 +++---- setup.py | 1 - tests/__init__.py | 2 +- 14 files changed, 21 insertions(+), 27 deletions(-) diff --git a/dataframe_image/__init__.py b/dataframe_image/__init__.py index 46a11bf..01451d0 100644 --- a/dataframe_image/__init__.py +++ b/dataframe_image/__init__.py @@ -1,3 +1,5 @@ from ._convert import convert from ._pandas_accessor import export, export_async from ._version import __version__ + +__all__ = ["export", "export_async", "convert", "__version__"] \ No newline at end of file diff --git a/dataframe_image/_browser_pdf.py b/dataframe_image/_browser_pdf.py index 79910b8..8955cad 100644 --- a/dataframe_image/_browser_pdf.py +++ b/dataframe_image/_browser_pdf.py @@ -5,14 +5,12 @@ import os import platform import socket -import urllib.parse from pathlib import Path from subprocess import Popen -from tempfile import TemporaryDirectory, mkstemp +from tempfile import mkstemp import aiohttp -from nbconvert import TemplateExporter -from nbconvert.exporters import Exporter, HTMLExporter +from nbconvert.exporters import HTMLExporter from .converter.browser.chrome_converter import get_chrome_path @@ -141,7 +139,7 @@ def get_pdf_data(file_name): def get_pdf_data_chromecontroller(file_name): - import ChromeController + import ChromeController # type: ignore additional_options = get_launch_args() # ChromeContext will shlex.split binary, so add quote to it @@ -150,10 +148,10 @@ def get_pdf_data_chromecontroller(file_name): ) as cr: # Do a blocking navigate to a URL, and get the page content as served by the remote # server, with no modification by local javascript (if applicable) - raw_source = cr.blocking_navigate_and_get_source(file_name) + # raw_source = cr.blocking_navigate_and_get_source(file_name) # Since the page is now rendered by the blocking navigate, we can # get the page source after any javascript has modified it. - rendered_source = cr.get_rendered_page_source() + # rendered_source = cr.get_rendered_page_source() # # Or take a screenshot # # The screenshot is the size of the remote browser's configured viewport, # # which by default is set to 1024 * 1366. This size can be changed via the diff --git a/dataframe_image/_bundler.py b/dataframe_image/_bundler.py index 2e011c2..86b55c9 100644 --- a/dataframe_image/_bundler.py +++ b/dataframe_image/_bundler.py @@ -1,8 +1,6 @@ import base64 -import json from pathlib import Path -from tornado import gen def _jupyter_bundlerextension_paths(): diff --git a/dataframe_image/_convert.py b/dataframe_image/_convert.py index b1821e5..ab1f8d7 100644 --- a/dataframe_image/_convert.py +++ b/dataframe_image/_convert.py @@ -1,11 +1,7 @@ -import base64 import io import logging import os -import re import shutil -import tempfile -import time import urllib.parse import warnings from pathlib import Path diff --git a/dataframe_image/_latex_pdf.py b/dataframe_image/_latex_pdf.py index e3d407a..35641fa 100644 --- a/dataframe_image/_latex_pdf.py +++ b/dataframe_image/_latex_pdf.py @@ -1,6 +1,6 @@ import shutil -from nbconvert.exporters import Exporter, HTMLExporter, PDFExporter +from nbconvert.exporters import PDFExporter from ._preprocessors import ( ChangeOutputTypePreprocessor, diff --git a/dataframe_image/_preprocessors.py b/dataframe_image/_preprocessors.py index 09f1a4b..20badc3 100644 --- a/dataframe_image/_preprocessors.py +++ b/dataframe_image/_preprocessors.py @@ -1,5 +1,4 @@ import base64 -import io import re from pathlib import Path diff --git a/dataframe_image/converter/__init__.py b/dataframe_image/converter/__init__.py index 87b3d33..b00b979 100644 --- a/dataframe_image/converter/__init__.py +++ b/dataframe_image/converter/__init__.py @@ -1 +1 @@ -from .browser import * +from .browser import * # noqa: F403 diff --git a/dataframe_image/converter/browser/__init__.py b/dataframe_image/converter/browser/__init__.py index 42d5d12..0cc2e4b 100644 --- a/dataframe_image/converter/browser/__init__.py +++ b/dataframe_image/converter/browser/__init__.py @@ -2,3 +2,11 @@ from .html2image_converter import Html2ImageConverter from .playwright_converter import AsyncPlayWrightConverter, PlayWrightConverter from .selenium_converter import SeleniumConverter + +__all__ = [ + "ChromeConverter", + "Html2ImageConverter", + "PlayWrightConverter", + "AsyncPlayWrightConverter", + "SeleniumConverter", +] \ No newline at end of file diff --git a/dataframe_image/converter/browser/base.py b/dataframe_image/converter/browser/base.py index cc7e144..58be38c 100644 --- a/dataframe_image/converter/browser/base.py +++ b/dataframe_image/converter/browser/base.py @@ -1,10 +1,8 @@ import base64 import io import logging -import subprocess from abc import ABC from pathlib import Path -from tempfile import TemporaryDirectory import numpy as np from PIL import Image, ImageOps diff --git a/dataframe_image/converter/browser/playwright_converter.py b/dataframe_image/converter/browser/playwright_converter.py index 2f3625f..da95a7d 100644 --- a/dataframe_image/converter/browser/playwright_converter.py +++ b/dataframe_image/converter/browser/playwright_converter.py @@ -1,7 +1,5 @@ import math from io import BytesIO -from pathlib import Path -from tempfile import TemporaryDirectory from PIL import Image diff --git a/dataframe_image/converter/browser/selenium_converter.py b/dataframe_image/converter/browser/selenium_converter.py index 511b8fd..0f6effc 100644 --- a/dataframe_image/converter/browser/selenium_converter.py +++ b/dataframe_image/converter/browser/selenium_converter.py @@ -1,4 +1,3 @@ -import logging from pathlib import Path from tempfile import TemporaryDirectory diff --git a/dataframe_image/converter/matplotlib_table.py b/dataframe_image/converter/matplotlib_table.py index 689f95d..797c73f 100644 --- a/dataframe_image/converter/matplotlib_table.py +++ b/dataframe_image/converter/matplotlib_table.py @@ -5,7 +5,6 @@ import cssutils import numpy as np from lxml.cssselect import CSSSelector -from lxml.etree import tostring from lxml.html import fromstring from matplotlib import lines as mlines from matplotlib import patches as mpatches @@ -93,8 +92,8 @@ def get_property(element, property_name): def parse_row(row): values = [] - rowspan_dict = {} - colspan_total = 0 + # rowspan_dict = {} + # colspan_total = 0 row_align = self.get_text_align(row) for el in row.xpath(".//td|.//th"): bold = el.tag == "th" @@ -169,7 +168,7 @@ def get_all_text_widths(self, rows): ) row_widths.append(cell_max_width) all_text_widths.append(row_widths) - pad = 10 # number of pixels to pad columns with + # pad = 10 # number of pixels to pad columns with return np.array(all_text_widths) + 15 def calculate_col_widths(self): diff --git a/setup.py b/setup.py index 9d89028..54764d5 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,3 @@ -import re import setuptools diff --git a/tests/__init__.py b/tests/__init__.py index 1198752..3797c6c 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1 +1 @@ -from . import conftest +from . import conftest # noqa: F401