Skip to content

Commit 7ca4004

Browse files
committed
Merge branch 'feature/fix-mfr-tests' into feature/buff-worms
Closes #384
2 parents 2df7510 + 7406f82 commit 7ca4004

30 files changed

+648
-531
lines changed

.github/workflows/test-build.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ jobs:
6666
run: poetry run flake8 .
6767

6868
- name: Build plugins
69-
run: poetry run python setup.py develop
69+
run: |
70+
python3 setup.py egg_info
71+
poetry run pip install .
7072
7173
- name: Run unit tests
7274
run: |

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ COPY ./ /code/
5858
ARG GIT_COMMIT=
5959
ENV GIT_COMMIT=${GIT_COMMIT}
6060

61-
RUN poetry run python setup.py develop
61+
RUN python3 setup.py egg_info
62+
RUN python3 -m pip install .
6263

6364
EXPOSE 7778
6465

mfr/__init__.py

Lines changed: 0 additions & 3 deletions
This file was deleted.

mfr/core/exceptions.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class ExtensionError(PluginError):
4646

4747
__TYPE = 'extension'
4848

49-
def __init__(self, message, *args, extension: str='', **kwargs):
49+
def __init__(self, message, *args, extension: str = '', **kwargs):
5050
super().__init__(message, *args, **kwargs)
5151
self.extension = extension
5252
self.attr_stack.append([self.__TYPE, {'extension': self.extension}])
@@ -59,7 +59,7 @@ class RendererError(ExtensionError):
5959

6060
__TYPE = 'renderer'
6161

62-
def __init__(self, message, *args, renderer_class: str='', **kwargs):
62+
def __init__(self, message, *args, renderer_class: str = '', **kwargs):
6363
super().__init__(message, *args, **kwargs)
6464
self.renderer_class = renderer_class
6565
self.attr_stack.append([self.__TYPE, {'class': self.renderer_class}])
@@ -72,7 +72,7 @@ class ExporterError(ExtensionError):
7272

7373
__TYPE = 'exporter'
7474

75-
def __init__(self, message, *args, exporter_class: str='', **kwargs):
75+
def __init__(self, message, *args, exporter_class: str = '', **kwargs):
7676
super().__init__(message, *args, **kwargs)
7777
self.exporter_class = exporter_class
7878
self.attr_stack.append([self.__TYPE, {'exporter_class': self.exporter_class}])
@@ -85,8 +85,8 @@ class SubprocessError(ExporterError):
8585

8686
__TYPE = 'subprocess'
8787

88-
def __init__(self, message, *args, code: int=500, process: str='', cmd: str='',
89-
returncode: int=None, path: str='', **kwargs):
88+
def __init__(self, message, *args, code: int = 500, process: str = '', cmd: str = '',
89+
returncode: int = None, path: str = '', **kwargs):
9090
super().__init__(message, *args, code=code, **kwargs)
9191
self.process = process
9292
self.cmd = cmd
@@ -107,7 +107,7 @@ class ProviderError(PluginError):
107107

108108
__TYPE = 'provider'
109109

110-
def __init__(self, message, *args, provider: str='', **kwargs):
110+
def __init__(self, message, *args, provider: str = '', **kwargs):
111111
super().__init__(message, *args, **kwargs)
112112
self.provider = provider
113113
self.attr_stack.append([self.__TYPE, {'provider': self.provider}])
@@ -120,7 +120,7 @@ class DownloadError(ProviderError):
120120

121121
__TYPE = 'download'
122122

123-
def __init__(self, message, *args, download_url: str='', response: str='', **kwargs):
123+
def __init__(self, message, *args, download_url: str = '', response: str = '', **kwargs):
124124
super().__init__(message, *args, **kwargs)
125125
self.download_url = download_url
126126
self.response = response
@@ -137,7 +137,7 @@ class MetadataError(ProviderError):
137137

138138
__TYPE = 'metadata'
139139

140-
def __init__(self, message, *args, metadata_url: str='', response: str='', **kwargs):
140+
def __init__(self, message, *args, metadata_url: str = '', response: str = '', **kwargs):
141141
super().__init__(message, *args, **kwargs)
142142
self.metadata_url = metadata_url
143143
self.response = response
@@ -153,8 +153,8 @@ class TooBigToRenderError(ProviderError):
153153

154154
__TYPE = 'too_big_to_render'
155155

156-
def __init__(self, message, *args, requested_size: int=None, maximum_size: int=None,
157-
code: int=400, **kwargs):
156+
def __init__(self, message, *args, requested_size: int = None, maximum_size: int = None,
157+
code: int = 400, **kwargs):
158158
super().__init__(message, *args, code=code, **kwargs)
159159
self.requested_size = requested_size
160160
self.maximum_size = maximum_size
@@ -168,8 +168,8 @@ class DriverManagerError(PluginError):
168168

169169
__TYPE = 'drivermanager'
170170

171-
def __init__(self, message, *args, namespace: str='', name: str='', invoke_on_load: bool=None,
172-
invoke_args: dict=None, **kwargs):
171+
def __init__(self, message, *args, namespace: str = '', name: str = '', invoke_on_load: bool = None,
172+
invoke_args: dict = None, **kwargs):
173173
super().__init__(message, *args, **kwargs)
174174

175175
self.namespace = namespace
@@ -189,7 +189,7 @@ class MakeProviderError(DriverManagerError):
189189
"""Thrown when MFR can't find an applicable provider class. This indicates programmer error,
190190
so ``code`` defaults to ``500``."""
191191

192-
def __init__(self, message, *args, code: int=500, **kwargs):
192+
def __init__(self, message, *args, code: int = 500, **kwargs):
193193
super().__init__(message, *args, code=code, **kwargs)
194194

195195

@@ -201,7 +201,7 @@ class UnsupportedExtensionError(DriverManagerError):
201201

202202
__TYPE = 'unsupported_extension'
203203

204-
def __init__(self, *args, code: int=400, handler_type: str='', **kwargs):
204+
def __init__(self, *args, code: int = 400, handler_type: str = '', **kwargs):
205205
super().__init__(*args, code=code, **kwargs)
206206

207207
self.handler_type = handler_type

mfr/core/remote_logging.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,7 @@ async def log_analytics(request, metrics, is_error=False):
8484
domain='private')
8585

8686
if (
87-
keen_payload['handler']['type'] != 'render' or
88-
file_metadata is None or
89-
is_error or
90-
not settings.KEEN_PUBLIC_LOG_VIEWS
87+
keen_payload['handler']['type'] != 'render' or file_metadata is None or is_error or not settings.KEEN_PUBLIC_LOG_VIEWS
9188
):
9289
return
9390

mfr/core/utils.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,15 @@ def get_renderer_name(name: str) -> str:
114114
# `ep_iterator` is an iterable object. Must convert it to a `list` for access.
115115
# `list()` can only be called once because the iterator moves to the end after conversion.
116116
ep = entry_points().select(group='mfr.renderers', name=name.lower())
117+
ep_list = list(ep)
117118

118119
# Empty list indicates unsupported file type. Return '' and let `make_renderer()` handle it.
119-
if len(ep) == 0:
120+
if len(ep_list) == 0:
120121
return ''
121122

122123
# If the file type is supported, there must be only one element in the list.
123-
assert len(ep) == 1
124-
return ep[0].value.split(":")[1].split('.')[0]
124+
assert len(ep_list) == 1
125+
return ep_list[0].value.split(":")[-1]
125126

126127

127128
def get_exporter_name(name: str) -> str:
@@ -135,14 +136,15 @@ def get_exporter_name(name: str) -> str:
135136
# `ep_iterator` is an iterable object. Must convert it to a `list` for access.
136137
# `list()` can only be called once because the iterator moves to the end after conversion.
137138
ep = entry_points().select(group='mfr.exporters', name=name.lower())
139+
ep_list = list(ep)
138140

139141
# Empty list indicates unsupported export type. Return '' and let `make_exporter()` handle it.
140-
if len(ep) == 0:
142+
if len(ep_list) == 0:
141143
return ''
142144

143145
# If the export type is supported, there must be only one element in the list.
144-
assert len(ep) == 1
145-
return ep[0].value.split(":")[1].split('.')[0]
146+
assert len(ep_list) == 1
147+
return ep_list[0].value.split(":")[-1]
146148

147149

148150
def sizeof_fmt(num, suffix='B'):

mfr/extensions/codepygments/exceptions.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class FileTooLargeError(CodePygmentsRendererError):
1313

1414
__TYPE = 'codepygments_file_too_large'
1515

16-
def __init__(self, message, *args, code: int=400, file_size: int=None, max_size: int=None,
16+
def __init__(self, message, *args, code: int = 400, file_size: int = None, max_size: int = None,
1717
**kwargs):
1818
super().__init__(message, *args, code=code, **kwargs)
1919

@@ -33,8 +33,8 @@ class FileDecodingError(CodePygmentsRendererError):
3333

3434
__TYPE = 'codepygments_file_decoding'
3535

36-
def __init__(self, message, *args, code: int=400, original_exception: Exception=None,
37-
category: str='', **kwargs):
36+
def __init__(self, message, *args, code: int = 400, original_exception: Exception = None,
37+
category: str = '', **kwargs):
3838
super().__init__(message, *args, code=code, **kwargs)
3939

4040
self.category = category

mfr/extensions/image/exceptions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ class PillowImageError(ExporterError):
88

99
__TYPE = 'image_pillow'
1010

11-
def __init__(self, message, *args, export_format: str='', detected_format: str='',
12-
original_exception: Exception=None, **kwargs):
11+
def __init__(self, message, *args, export_format: str = '', detected_format: str = '',
12+
original_exception: Exception = None, **kwargs):
1313
super().__init__(message, *args, exporter_class='image', **kwargs)
1414

1515
self.export_format = export_format

mfr/extensions/image/export.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def export(self):
7171
'Unable to export the file as a {}, please check that the '
7272
'file is a valid image.'.format(image_type),
7373
export_format=image_type,
74-
detected_format= self.detect_image_format(),
74+
detected_format=self.detect_image_format(),
7575
original_exception=err,
7676
code=400,
7777
)

mfr/extensions/ipynb/exceptions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ class InvalidFormatError(RendererError):
55

66
__TYPE = 'ipynb_invalid_format'
77

8-
def __init__(self, message, *args, code: int=400, download_url: str='',
9-
original_exception: Exception=None, **kwargs):
8+
def __init__(self, message, *args, code: int = 400, download_url: str = '',
9+
original_exception: Exception = None, **kwargs):
1010
super().__init__(message, *args, code=code, renderer_class='ipynb', **kwargs)
1111

1212
self.download_url = download_url,

0 commit comments

Comments
 (0)