Skip to content

Commit 2ac39cf

Browse files
committed
Pass mypy and link issues
1 parent 4e062b0 commit 2ac39cf

File tree

6 files changed

+35
-30
lines changed

6 files changed

+35
-30
lines changed

build-exe.py

+12-15
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,10 @@
22
Build script to create a doc-to-pdf convert server as a Windows executable.
33
"""
44

5-
import os
6-
import textwrap
7-
8-
9-
setup_params = dict(
10-
console=['server.py'],
11-
options=dict(
12-
py2exe=dict(
13-
packages=['pkg_resources'],
14-
),
15-
),
16-
script_args=('py2exe',),
17-
)
18-
195
if __name__ == '__main__':
6+
import os
7+
import textwrap
8+
209
from setuptools import setup
2110

2211
__import__('py2exe')
@@ -25,5 +14,13 @@
2514
convert.ConvertServer.start_server()
2615
"""
2716
open('server.py', 'w').write(textwrap.dedent(code))
28-
setup(**setup_params)
17+
setup(
18+
console=['server.py'],
19+
options=dict(
20+
py2exe=dict(
21+
packages=['pkg_resources'],
22+
),
23+
),
24+
script_args=('py2exe',), # type: ignore[arg-type] # python/typeshed#12595
25+
)
2926
os.remove('server.py')

jaraco/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: ignore
1+
__path__ = __import__('pkgutil').extend_path(__path__, __name__)

jaraco/office/convert.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import os
21
import argparse
2+
import os
33
from contextlib import contextmanager
44

5-
from jaraco.path import save_to_file, replace_extension
5+
from jaraco.path import replace_extension, save_to_file
66

77

88
@contextmanager
@@ -23,10 +23,11 @@ class Converter:
2323
"""
2424

2525
def __init__(self):
26-
from win32com.client import Dispatch
27-
import pythoncom
2826
import threading
2927

28+
import pythoncom
29+
from win32com.client import Dispatch
30+
3031
if threading.current_thread().getName() != 'MainThread':
3132
pythoncom.CoInitialize()
3233
self.word = Dispatch('Word.Application')
@@ -80,13 +81,13 @@ class ConvertServer:
8081
def index(self):
8182
return form
8283

83-
index.exposed = True # type: ignore
84+
index.exposed = True # type: ignore[attr-defined]
8485

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

89-
convert.exposed = True # type: ignore
90+
convert.exposed = True # type: ignore[attr-defined]
9091

9192
@staticmethod
9293
def start_server():

jaraco/office/grep.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import re
1+
from __future__ import annotations
22

3-
from win32com.client import Dispatch
3+
import re
44

5+
from win32com.client import Dispatch, dynamic
56

67
try:
7-
app = Dispatch('Excel.Application')
8+
app: dynamic.CDispatch | None = Dispatch('Excel.Application')
89
except Exception:
910
app = None
1011

mypy.ini

+8
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,11 @@ explicit_package_bases = True
1313
disable_error_code =
1414
# Disable due to many false positives
1515
overload-overlap,
16+
17+
# jaraco/jaraco.path#2
18+
[mypy-jaraco.path.*]
19+
ignore_missing_imports = True
20+
21+
# cherrypy/cherrypy#1510
22+
[mypy-cherrypy.*]
23+
ignore_missing_imports = True

pyproject.toml

+3-5
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ test = [
3333
"pytest >= 6, != 8.1.*",
3434

3535
# local
36-
'pypiwin32; platform_system == "Windows"',
36+
'pywin32; platform_system == "Windows"',
3737
]
3838

3939
doc = [
@@ -65,6 +65,8 @@ type = [
6565
"pytest-mypy",
6666

6767
# local
68+
"types-pywin32",
69+
"types-setuptools",
6870
]
6971

7072

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

7577

7678
[tool.setuptools_scm]
77-
78-
79-
[tool.pytest-enabler.mypy]
80-
# Disabled due to jaraco/skeleton#143

0 commit comments

Comments
 (0)