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

Fix mypy typing issues #136

Merged
merged 3 commits into from
Jun 17, 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
8 changes: 4 additions & 4 deletions formfyxer/docx_wrangling.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ def add_run_after(run, text):


def update_docx(
document: Union[docx.Document, str], modified_runs: List[Tuple[int, int, str, int]]
) -> docx.Document:
document: Union[docx.document.Document, str], modified_runs: List[Tuple[int, int, str, int]]
) -> docx.document.Document:
"""Update the document with the modified runs.

Note: OpenAI is probabilistic, so the modified run indices may not be correct.
Expand Down Expand Up @@ -416,7 +416,7 @@ def get_modified_docx_runs(
guesses = json.loads(response.choices[0].message.content)["results"]
return guesses

def make_docx_plain_language(docx_path: str) -> docx.Document:
def make_docx_plain_language(docx_path: str) -> docx.document.Document:
"""
Convert a DOCX file to plain language with the help of OpenAI.
"""
Expand All @@ -443,7 +443,7 @@ def make_docx_plain_language(docx_path: str) -> docx.Document:
)
return update_docx(docx.Document(docx_path), guesses)

def modify_docx_with_openai_guesses(docx_path: str) -> docx.Document:
def modify_docx_with_openai_guesses(docx_path: str) -> docx.document.Document:
"""Uses OpenAI to guess the variable names for a document and then modifies the document with the guesses.

Args:
Expand Down
4 changes: 2 additions & 2 deletions formfyxer/pdf_wrangling.py
Original file line number Diff line number Diff line change
Expand Up @@ -1152,8 +1152,8 @@ def get_possible_radios(img: Union[str, BinaryIO, cv2.Mat]):
maxRadius=50,
)
if circles is not None:
circles = np.uint16(np.around(circles))
for i in circles[0, :]:
rounded_circles = np.around(circles)
for i in rounded_circles[0, :]:
center = (i[0], i[1])
# circle center
cv2.circle(img_mat, center, 1, (0, 100, 100), 3)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def run(self):
license='MIT',
packages=['formfyxer'],
install_requires=['spacy', 'pdfminer.six', 'pandas', 'pikepdf',
'textstat', 'requests', 'numpy', 'scikit-learn==1.2.2', 'networkx', 'joblib',
'textstat', 'requests', 'numpy<2.0.0', 'scikit-learn==1.2.2', 'networkx', 'joblib',
'nltk', 'boxdetect', 'pdf2image', 'reportlab>=3.6.13', 'pdfminer.six',
'opencv-python', 'ocrmypdf', 'eyecite', 'passivepy>=0.2.16', 'sigfig',
'typer>=0.4.1,<0.5.0', # typer pre 0.4.1 was broken by click 8.1.0: https://github.com/explosion/spaCy/issues/10564
Expand Down