Skip to content

Commit

Permalink
Fix pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
vinayak-mehta committed Dec 26, 2024
1 parent 545da3e commit fe853c6
Show file tree
Hide file tree
Showing 10 changed files with 74 additions and 50 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ repos:
entry: end-of-file-fixer
language: system
types: [text]
stages: [commit, push, manual]
stages: [pre-commit, pre-push, manual]
- id: flake8
name: flake8
entry: flake8
Expand All @@ -52,7 +52,7 @@ repos:
entry: trailing-whitespace-fixer
language: system
types: [text]
stages: [commit, push, manual]
stages: [pre-commit, pre-push, manual]
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.6.0
hooks:
Expand Down
6 changes: 5 additions & 1 deletion camelot/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@

import click


try:
import matplotlib.pyplot as plt
except ImportError:
_HAS_MPL = False
else:
_HAS_MPL = True

from . import __version__, plot, read_pdf
from . import __version__
from . import plot
from . import read_pdf


logger = logging.getLogger("camelot")
logger.setLevel(logging.INFO)
Expand Down
20 changes: 10 additions & 10 deletions camelot/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,25 @@
import tempfile
import zipfile
from operator import itemgetter
from typing import Any, Iterable, Iterator
from typing import Any
from typing import Iterable
from typing import Iterator

import cv2
import pandas as pd


if sys.version_info >= (3, 11):
from typing import (
TypedDict, # pylint: disable=no-name-in-module
Unpack,
)
from typing import TypedDict # pylint: disable=no-name-in-module
from typing import Unpack
else:
from typing_extensions import TypedDict, Unpack

from .backends import ImageConversionBackend
from .utils import (
build_file_path_in_temp_dir,
get_index_closest_point,
get_textline_coords,
)
from .utils import build_file_path_in_temp_dir
from .utils import get_index_closest_point
from .utils import get_textline_coords


# minimum number of vertical textline intersections for a textedge
# to be considered valid
Expand Down
28 changes: 17 additions & 11 deletions camelot/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,26 @@
from pathlib import Path
from typing import Any

from pdfminer.layout import LTChar, LTImage, LTTextLineHorizontal, LTTextLineVertical
from pypdf import PdfReader, PdfWriter
from pdfminer.layout import LTChar
from pdfminer.layout import LTImage
from pdfminer.layout import LTTextLineHorizontal
from pdfminer.layout import LTTextLineVertical
from pypdf import PdfReader
from pypdf import PdfWriter
from pypdf._utils import StrByteType

from .core import TableList
from .parsers import Hybrid, Lattice, Network, Stream
from .utils import (
TemporaryDirectory,
download_url,
get_image_char_and_text_objects,
get_page_layout,
get_rotation,
is_url,
)
from .parsers import Hybrid
from .parsers import Lattice
from .parsers import Network
from .parsers import Stream
from .utils import TemporaryDirectory
from .utils import download_url
from .utils import get_image_char_and_text_objects
from .utils import get_page_layout
from .utils import get_rotation
from .utils import is_url


PARSERS = {
"lattice": Lattice,
Expand Down
12 changes: 5 additions & 7 deletions camelot/parsers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@
import pandas as pd

from ..core import Table
from ..utils import (
bbox_from_str,
compute_accuracy,
compute_whitespace,
get_table_index,
text_in_bbox,
)
from ..utils import bbox_from_str
from ..utils import compute_accuracy
from ..utils import compute_whitespace
from ..utils import get_table_index
from ..utils import text_in_bbox


class BaseParser:
Expand Down
37 changes: 21 additions & 16 deletions camelot/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,35 @@
from itertools import groupby
from operator import itemgetter
from pathlib import Path
from typing import Any, Callable
from typing import Any
from typing import Callable
from urllib.parse import urlparse as parse_url
from urllib.parse import uses_netloc, uses_params, uses_relative
from urllib.request import Request, urlopen
from urllib.parse import uses_netloc
from urllib.parse import uses_params
from urllib.parse import uses_relative
from urllib.request import Request
from urllib.request import urlopen

import numpy as np
from pdfminer.converter import PDFPageAggregator
from pdfminer.layout import (
LAParams,
LTAnno,
LTChar,
LTContainer,
LTImage,
LTItem,
LTTextLine,
LTTextLineHorizontal,
LTTextLineVertical,
)
from pdfminer.layout import LAParams
from pdfminer.layout import LTAnno
from pdfminer.layout import LTChar
from pdfminer.layout import LTContainer
from pdfminer.layout import LTImage
from pdfminer.layout import LTItem
from pdfminer.layout import LTTextLine
from pdfminer.layout import LTTextLineHorizontal
from pdfminer.layout import LTTextLineVertical
from pdfminer.pdfdocument import PDFDocument
from pdfminer.pdfinterp import PDFPageInterpreter, PDFResourceManager
from pdfminer.pdfpage import PDFPage, PDFTextExtractionNotAllowed
from pdfminer.pdfinterp import PDFPageInterpreter
from pdfminer.pdfinterp import PDFResourceManager
from pdfminer.pdfpage import PDFPage
from pdfminer.pdfpage import PDFTextExtractionNotAllowed
from pdfminer.pdfparser import PDFParser
from pypdf._utils import StrByteType


_VALID_URLS = set(uses_relative + uses_netloc + uses_params)
_VALID_URLS.discard("")

Expand Down
6 changes: 6 additions & 0 deletions docs/_themes/flask_theme_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@


class FlaskyStyle(Style):
"""A Pygments style based on the Flask theme colors.
This style uses a light gray background (#f8f8f8) and default text styling.
It is used for syntax highlighting code blocks in Flask's documentation.
"""

background_color = "#f8f8f8"
default_style = ""

Expand Down
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import camelot


# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
Expand Down
4 changes: 3 additions & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
from textwrap import dedent

import nox
from nox import Session, session
from nox import Session
from nox import session


package = "camelot"

Expand Down
6 changes: 4 additions & 2 deletions tests/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@

import camelot
from camelot.backends.ghostscript_backend import GhostscriptBackend
from camelot.core import Table, TableList
from camelot.core import Table
from camelot.core import TableList
from camelot.io import PDFHandler

from .conftest import skip_on_windows, skip_pdftopng
from .conftest import skip_on_windows
from .conftest import skip_pdftopng
from .data import *


Expand Down

0 comments on commit fe853c6

Please sign in to comment.