Skip to content

Commit

Permalink
Pass mypy and link issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Avasam committed Aug 26, 2024
1 parent 56dbb26 commit 80bf791
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 29 deletions.
27 changes: 12 additions & 15 deletions build-exe.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,10 @@
Build script to create a doc-to-pdf convert server as a Windows executable.
"""

import os
import textwrap


setup_params = dict(
console=['server.py'],
options=dict(
py2exe=dict(
packages=['pkg_resources'],
),
),
script_args=('py2exe',),
)

if __name__ == '__main__':
import os
import textwrap

from setuptools import setup

__import__('py2exe')
Expand All @@ -25,5 +14,13 @@
convert.ConvertServer.start_server()
"""
open('server.py', 'w').write(textwrap.dedent(code))
setup(**setup_params)
setup(
console=['server.py'],
options=dict(
py2exe=dict(
packages=['pkg_resources'],
),
),
script_args=('py2exe',), # type: ignore[arg-type] # TODO: Fix in typeshed's types-setuptools
)
os.remove('server.py')
2 changes: 1 addition & 1 deletion jaraco/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: ignore
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
13 changes: 7 additions & 6 deletions jaraco/office/convert.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import os
import argparse
import os
from contextlib import contextmanager

from jaraco.path import save_to_file, replace_extension
from jaraco.path import replace_extension, save_to_file


@contextmanager
Expand All @@ -23,10 +23,11 @@ class Converter:
"""

def __init__(self):
from win32com.client import Dispatch
import pythoncom
import threading

import pythoncom
from win32com.client import Dispatch

if threading.current_thread().getName() != 'MainThread':
pythoncom.CoInitialize()
self.word = Dispatch('Word.Application')
Expand Down Expand Up @@ -80,13 +81,13 @@ class ConvertServer:
def index(self):
return form

index.exposed = True # type: ignore
index.exposed = True # type: ignore[attr-defined]

def convert(self, document):
cherrypy.response.headers['Content-Type'] = 'application/pdf'
return Converter().convert(document.file.read())

convert.exposed = True # type: ignore
convert.exposed = True # type: ignore[attr-defined]

@staticmethod
def start_server():
Expand Down
7 changes: 4 additions & 3 deletions jaraco/office/grep.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import re
from __future__ import annotations

from win32com.client import Dispatch
import re

from win32com.client import Dispatch, dynamic

try:
app = Dispatch('Excel.Application')
app: dynamic.CDispatch | None = Dispatch('Excel.Application')
except Exception:
app = None

Expand Down
8 changes: 8 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,11 @@ explicit_package_bases = True

# Disable overload-overlap due to many false-positives
disable_error_code = overload-overlap

# jaraco/jaraco.path#2
[mypy-jaraco.path.*]
ignore_missing_imports = True

# cherrypy/cherrypy#1510
[mypy-cherrypy.*]
ignore_missing_imports = True
6 changes: 2 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ type = [
"pytest-mypy",

# local
"types-pywin32",
"types-setuptools",
]


Expand All @@ -74,7 +76,3 @@ doc-to-pdf-server = "jaraco.office.convert:ConvertServer.start_server"


[tool.setuptools_scm]


[tool.pytest-enabler.mypy]
# Disabled due to jaraco/skeleton#143

0 comments on commit 80bf791

Please sign in to comment.