Merge ~jugmac00/lazr.restful:add-pre-commit into lazr.restful:main

Proposed by Jürgen Gmach
Status: Merged
Merge reported by: Jürgen Gmach
Merged at revision: 8f102749f330820105f55690032f79e8e55918a0
Proposed branch: ~jugmac00/lazr.restful:add-pre-commit
Merge into: lazr.restful:main
Diff against target: 1163 lines (+161/-85)
40 files modified
.pre-commit-config.yaml (+15/-0)
NEWS.rst (+1/-0)
setup.py (+3/-1)
src/lazr/restful/__init__.py (+3/-3)
src/lazr/restful/_operation.py (+1/-1)
src/lazr/restful/_resource.py (+15/-21)
src/lazr/restful/declarations.py (+7/-4)
src/lazr/restful/directives/__init__.py (+6/-1)
src/lazr/restful/docs/conf.py (+0/-3)
src/lazr/restful/error.py (+1/-0)
src/lazr/restful/example/base/filemanager.py (+4/-2)
src/lazr/restful/example/base/root.py (+7/-6)
src/lazr/restful/example/base/security.py (+0/-1)
src/lazr/restful/example/base/subscribers.py (+1/-0)
src/lazr/restful/example/base/tests/test_integration.py (+4/-0)
src/lazr/restful/example/base_extended/tests/test_integration.py (+4/-0)
src/lazr/restful/example/multiversion/resources.py (+1/-0)
src/lazr/restful/example/multiversion/root.py (+0/-1)
src/lazr/restful/example/multiversion/tests/test_integration.py (+4/-0)
src/lazr/restful/example/wsgi/root.py (+0/-1)
src/lazr/restful/example/wsgi/tests/test_integration.py (+4/-0)
src/lazr/restful/frameworks/django.py (+6/-0)
src/lazr/restful/interface.py (+0/-1)
src/lazr/restful/interfaces/__init__.py (+2/-2)
src/lazr/restful/interfaces/_fields.py (+1/-0)
src/lazr/restful/interfaces/_rest.py (+4/-1)
src/lazr/restful/jsoncache.py (+1/-0)
src/lazr/restful/marshallers.py (+1/-1)
src/lazr/restful/metazcml.py (+6/-6)
src/lazr/restful/security.py (+0/-2)
src/lazr/restful/simple.py (+0/-2)
src/lazr/restful/tales.py (+1/-2)
src/lazr/restful/testing/event.py (+0/-1)
src/lazr/restful/testing/tales.py (+0/-1)
src/lazr/restful/testing/webservice.py (+0/-1)
src/lazr/restful/tests/test_declarations.py (+20/-12)
src/lazr/restful/tests/test_utils.py (+1/-2)
src/lazr/restful/tests/test_webservice.py (+7/-5)
src/lazr/restful/wsgi.py (+0/-1)
tox.ini (+30/-0)
Reviewer Review Type Date Requested Status
Colin Watson (community) Approve
Review via email: mp+411318@code.launchpad.net

Commit message

Add basic pre-commit configuration

Description of the change

flake8 was added as a hook, but some formatting issues were not touched, as they will be fixed when we use black.

Three more warnings were also not touched. Fixing these would result in a changed code/test meaning, which needs some more attention at a later time.

To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
2new file mode 100644
3index 0000000..45fd4ba
4--- /dev/null
5+++ b/.pre-commit-config.yaml
6@@ -0,0 +1,15 @@
7+# See https://pre-commit.com for more information
8+# See https://pre-commit.com/hooks.html for more hooks
9+repos:
10+- repo: https://github.com/pre-commit/pre-commit-hooks
11+ rev: v3.2.0
12+ hooks:
13+ - id: check-added-large-files
14+ - id: check-ast
15+ - id: check-merge-conflict
16+ - id: check-yaml
17+ - id: debug-statements
18+- repo: https://github.com/PyCQA/flake8
19+ rev: 3.9.2
20+ hooks:
21+ - id: flake8
22diff --git a/NEWS.rst b/NEWS.rst
23index 4245130..9a03a7e 100644
24--- a/NEWS.rst
25+++ b/NEWS.rst
26@@ -6,6 +6,7 @@ NEWS for lazr.restful
27 =====
28
29 - Add support for Python 3.9 and 3.10.
30+- Add basic pre-commit configuration.
31
32 1.1.0 (2021-10-07)
33 ==================
34diff --git a/setup.py b/setup.py
35index 29508ad..4fc49fc 100755
36--- a/setup.py
37+++ b/setup.py
38@@ -18,6 +18,7 @@
39
40 from setuptools import setup, find_packages
41
42+
43 # generic helpers primarily for the long_description
44 def generate(*docname_or_string):
45 res = []
46@@ -32,6 +33,7 @@ def generate(*docname_or_string):
47 return '\n'.join(res)
48 # end generic helpers
49
50+
51 setup(
52 name='lazr.restful',
53 version='1.1.0',
54@@ -99,7 +101,7 @@ setup(
55 extras_require=dict(
56 docs=['Sphinx'],
57 test=['zope.testing>=4.6.0'],
58- xml=['lxml',] # requiring this of normal users is too much
59+ xml=['lxml',] # requiring this of normal users is too much
60 ),
61 test_suite='lazr.restful.tests',
62 )
63diff --git a/src/lazr/restful/__init__.py b/src/lazr/restful/__init__.py
64index c8d4916..54321dc 100644
65--- a/src/lazr/restful/__init__.py
66+++ b/src/lazr/restful/__init__.py
67@@ -32,11 +32,11 @@ try:
68 # While we generally frown on "*" imports, this approach, combined with
69 # the fact we only test code from this module, means that we can verify
70 # what has been exported in the local files (DRY).
71- from lazr.restful._bytestorage import *
72+ from lazr.restful._bytestorage import * # noqa: F401, F403
73 from lazr.restful._bytestorage import __all__ as _bytestorage_all
74- from lazr.restful._operation import *
75+ from lazr.restful._operation import * # noqa: F401, F403
76 from lazr.restful._operation import __all__ as _operation_all
77- from lazr.restful._resource import *
78+ from lazr.restful._resource import * # noqa: F401, F403
79 from lazr.restful._resource import __all__ as _resource_all
80 __all__ = []
81 __all__.extend(_bytestorage_all)
82diff --git a/src/lazr/restful/_operation.py b/src/lazr/restful/_operation.py
83index ee1eee5..fc7c037 100644
84--- a/src/lazr/restful/_operation.py
85+++ b/src/lazr/restful/_operation.py
86@@ -157,7 +157,7 @@ class ResourceOperation(BatchingResourceMixin):
87 return False
88
89 try:
90- iterator = iter(result)
91+ iter(result)
92 # Objects that have iterators but aren't ordinary data structures
93 # tend to be result-set objects. Batch them.
94 return True
95diff --git a/src/lazr/restful/_resource.py b/src/lazr/restful/_resource.py
96index e12f5e3..0b411e8 100644
97--- a/src/lazr/restful/_resource.py
98+++ b/src/lazr/restful/_resource.py
99@@ -45,8 +45,8 @@ try:
100 import hashlib
101 sha_constructor = hashlib.sha1
102 except ImportError:
103- import sha
104- sha_constructor = sha.new
105+ import sha
106+ sha_constructor = sha.new
107
108 try:
109 from html import escape
110@@ -150,7 +150,7 @@ CLOSEUP_DETAIL = object()
111 # bug=https://bugs.edge.launchpad.net/zope3/+bug/322486:
112 # Add nonstandard status methods to Zope's status_reasons dictionary.
113 for code, reason in [(209, 'Content Returned')]:
114- if not code in status_reasons:
115+ if code not in status_reasons:
116 status_reasons[code] = reason
117 init_status_codes()
118
119@@ -314,7 +314,7 @@ class HTTPResource:
120
121 :return: The HTTP method to use.
122 """
123- if request == None:
124+ if request is None:
125 request = self.request
126 override = request.headers.get('X-HTTP-Method-Override')
127 if override is not None and request.method == 'POST':
128@@ -344,7 +344,7 @@ class HTTPResource:
129 if existing_etag in incoming_etags:
130 # The client already has this representation.
131 # No need to send it again.
132- self.request.response.setStatus(304) # Not Modified
133+ self.request.response.setStatus(304) # Not Modified
134 media_type = None
135 return media_type
136
137@@ -617,7 +617,6 @@ class BatchingResourceMixin:
138
139 return simplejson.dumps(len(entries))
140
141-
142 def batch(self, entries, request):
143 """Prepare a batch from a (possibly huge) list of entries.
144
145@@ -645,7 +644,7 @@ class BatchingResourceMixin:
146 navigator = WebServiceBatchNavigator(entries, request)
147
148 view_permission = getUtility(IWebServiceConfiguration).view_permission
149- batch = { 'start' : navigator.batch.start }
150+ batch = {'start': navigator.batch.start}
151 # If this is the last batch, then total() is easy to
152 # calculate. Let's use it and save the client from having to
153 # ask for the total size of the collection.
154@@ -990,7 +989,7 @@ class EntryHTMLView:
155 namespace = self.HTML_TEMPLATE.pt_getContext()
156 names_and_values = self.resource.toDataStructure(
157 HTTPResource.XHTML_TYPE).items()
158- data = [{'name' : name, 'value': decode_value(value)}
159+ data = [{'name': name, 'value': decode_value(value)}
160 for name, value in names_and_values]
161 namespace['context'] = sorted(data, key=itemgetter('name'))
162 return self.HTML_TEMPLATE.pt_render(namespace)
163@@ -1076,7 +1075,7 @@ class EntryManipulatingResource(ReadWriteResource):
164 marshaller = getMultiAdapter((field, self.request),
165 IFieldMarshaller)
166 repr_name = marshaller.representation_name
167- if not repr_name in changeset:
168+ if repr_name not in changeset:
169 # The client didn't try to set a value for this field.
170 continue
171
172@@ -1146,7 +1145,7 @@ class EntryManipulatingResource(ReadWriteResource):
173 # ObjectLookupFieldMarshaller, once we make it
174 # possible for Vocabulary fields to specify a schema
175 # class the way IReference fields can.
176- if value != None and not field.schema.providedBy(value):
177+ if value is not None and not field.schema.providedBy(value):
178 errors.append(u"%s: Your value points to the "
179 "wrong kind of object" % repr_name)
180 continue
181@@ -1183,7 +1182,7 @@ class EntryManipulatingResource(ReadWriteResource):
182 error = "Constraint not satisfied."
183 errors.append(u"%s: %s" % (repr_name, error))
184 continue
185- except RequiredMissing as e:
186+ except RequiredMissing:
187 error = "Missing required value."
188 errors.append(u"%s: %s" % (repr_name, error))
189 except (ValueError, ValidationError) as e:
190@@ -1306,7 +1305,7 @@ class EntryFieldResource(FieldUnmarshallerMixin, EntryManipulatingResource):
191 value, error = self.processAsJSONDocument(media_type, representation)
192 if value is None:
193 return value, error
194- changeset = {self.context.name : value}
195+ changeset = {self.context.name: value}
196 return self.applyChanges(changeset, media_type)
197
198 do_PATCH = do_PUT
199@@ -1367,6 +1366,7 @@ class EntryFieldURL(AbsoluteURL):
200 self.context = entryfield
201 self.request = request
202
203+
204 def make_entry_etag_cores(field_details):
205 """Given the details of an entry's fields, calculate its ETag cores.
206
207@@ -1390,7 +1390,6 @@ def make_entry_etag_cores(field_details):
208 return [unwritable, writable]
209
210
211-
212 @implementer(IEntryResource, IJSONPublishable)
213 class EntryResource(CustomOperationResourceMixin,
214 FieldUnmarshallerMixin, EntryManipulatingResource):
215@@ -1465,7 +1464,6 @@ class EntryResource(CustomOperationResourceMixin,
216 existing_write_portion = extract_write_portion(existing_etag)
217 return existing_write_portion in incoming_write_portions
218
219-
220 def toDataForJSON(self, media_type=None):
221 """Turn the object into a simple data structure."""
222 return self.toDataStructure(media_type or self.JSON_TYPE)
223@@ -1612,7 +1610,6 @@ class EntryResource(CustomOperationResourceMixin,
224
225 return self.applyChanges(changeset, media_type)
226
227-
228 def do_PATCH(self, media_type, representation):
229 """Apply a JSON patch to the entry."""
230 changeset, error = self.processAsJSONHash(media_type, representation)
231@@ -1629,7 +1626,6 @@ class EntryResource(CustomOperationResourceMixin,
232 if cache is not None:
233 cache.delete(self.context)
234
235-
236 @property
237 def type_url(self):
238 """The URL to the resource type for this resource."""
239@@ -1643,7 +1639,6 @@ class EntryResource(CustomOperationResourceMixin,
240 """An EntryAdapterUtility for this resource."""
241 return EntryAdapterUtility(self.entry.__class__)
242
243-
244 @property
245 def redacted_fields(self):
246 """Names the fields the current user doesn't have permission to see."""
247@@ -1991,7 +1986,7 @@ class ServiceRootResource(HTTPResource):
248 # directly, it will always show up in
249 # providedBy(self.request).
250 continue
251- if not version_marker in providedBy(self.request):
252+ if version_marker not in providedBy(self.request):
253 continue
254
255 # Make sure that no other entry class is using this
256@@ -2042,7 +2037,7 @@ class ServiceRootResource(HTTPResource):
257 self.request.publication.getApplication(self.request),
258 self.request),
259 "service-root")
260- data_for_json = {'resource_type_link' : type_url}
261+ data_for_json = {'resource_type_link': type_url}
262 publications = self.getTopLevelPublications()
263 for link_name, publication in publications.items():
264 data_for_json[link_name] = absoluteURL(publication,
265@@ -2326,9 +2321,8 @@ def get_entry_fields_in_write_order(entry):
266 # it at the end -- it's probably controlled by a mutator.
267 implementation = field_implementations[name]
268 if (issubclass(implementation.__class__, Passthrough)
269- and not implementation.__class__ is Passthrough):
270+ and implementation.__class__ is not Passthrough):
271 mutator_fields.append((name, field))
272 else:
273 non_mutator_fields.append((name, field))
274 return non_mutator_fields + mutator_fields
275-
276diff --git a/src/lazr/restful/declarations.py b/src/lazr/restful/declarations.py
277index fa13b30..f1529de 100644
278--- a/src/lazr/restful/declarations.py
279+++ b/src/lazr/restful/declarations.py
280@@ -234,7 +234,7 @@ def _export_as_webservice_entry(interface,
281 # no 'as' is specified. Also set 'original_name' for every
282 # version in which the field is published--this will help with
283 # performance optimizations around permission checks.
284- if tags.get('exported') != False:
285+ if tags.get('exported') is not False:
286 tags['original_name'] = name
287 if tags.get('as') is None:
288 tags['as'] = name
289@@ -397,7 +397,7 @@ def exported(field, *versioned_annotations, **kwparams):
290 # the VersionedDict.
291 for (key, annotation_key) in annotation_key_for_argument_key.items():
292 if key in kwparams:
293- if (key == "exported" and kwparams[key] == False
294+ if (key == "exported" and kwparams[key] is False
295 and first_version_name is not None):
296 raise ValueError(
297 ("as_of=%s says to export %s, but exported=False "
298@@ -561,6 +561,7 @@ class collection_default_content:
299
300 WEBSERVICE_ERROR = '__lazr_webservice_error__'
301
302+
303 def webservice_error(status):
304 """Mark the exception with the HTTP status code to use.
305
306@@ -604,6 +605,7 @@ def error_status(status):
307 validation, its specified status won't propagate to the response.
308 """
309 status = int(status)
310+
311 def func(value):
312 if not issubclass(value, Exception):
313 raise TypeError('Annotated value must be an exception class.')
314@@ -668,7 +670,7 @@ class _method_annotator:
315 The annotations will copied to the lazr.webservice.exported tag
316 by a class advisor.
317 """
318- raise NotImplemented
319+ raise NotImplementedError
320
321
322 def annotate_exported_methods(interface):
323@@ -743,7 +745,7 @@ def _update_default_and_required_params(params, method_info):
324 # string.
325 if (six.PY2 and
326 isinstance(default, str) and IText.providedBy(param_def)):
327- default = unicode(default)
328+ default = unicode(default) # noqa: F821
329 param_def.default = default
330 param_def.required = False
331 elif name in required and param_def.default is not None:
332@@ -891,6 +893,7 @@ class operation_removed_in_version(operation_for_version):
333 # version from a method that was incompletely annotated.
334 annotations['type'] = REMOVED_OPERATION_TYPE
335
336+
337 class export_operation_as(_method_annotator):
338 """Decorator specifying the name to export the method as."""
339
340diff --git a/src/lazr/restful/directives/__init__.py b/src/lazr/restful/directives/__init__.py
341index 527c332..c695ea7 100644
342--- a/src/lazr/restful/directives/__init__.py
343+++ b/src/lazr/restful/directives/__init__.py
344@@ -7,7 +7,8 @@ from __future__ import absolute_import, print_function
345 __metaclass__ = type
346 __all__ = ['request_class',
347 'publication_class',
348- 'settings',]
349+ 'settings',
350+]
351
352 import martian
353 from zope.component import getSiteManager
354@@ -71,6 +72,7 @@ class ConfigurationGrokker(martian.ClassGrokker):
355 martian.component(BaseWebServiceConfiguration)
356 martian.directive(request_class)
357 martian.directive(publication_class)
358+
359 def execute(self, cls, config, request_class,
360 publication_class, *kw):
361 # If implementations of the IWebServiceConfiguration methods are
362@@ -114,6 +116,7 @@ class ConfigurationGrokker(martian.ClassGrokker):
363 class ServiceRootGrokker(martian.ClassGrokker):
364 """Registers your service root as a singleton object."""
365 martian.component(ServiceRootResource)
366+
367 def execute(self, cls, config, *kw):
368 getSiteManager().registerUtility(cls(), IServiceRootResource)
369 return True
370@@ -126,6 +129,7 @@ class RootResourceAbsoluteURLGrokker(martian.ClassGrokker):
371 RootResourceAbsoluteURL.
372 """
373 martian.component(RootResourceAbsoluteURL)
374+
375 def execute(self, cls, config, *kw):
376 getSiteManager().registerAdapter(cls)
377 return True
378@@ -149,6 +153,7 @@ class AbsoluteURLGrokker(martian.ClassGrokker):
379 """
380 martian.component(AbsoluteURL)
381 martian.directive(location_interface)
382+
383 def execute(self, cls, config, location_interface, *kw):
384 getSiteManager().registerAdapter(
385 cls, (location_interface, IWebServiceLayer), IAbsoluteURL)
386diff --git a/src/lazr/restful/docs/conf.py b/src/lazr/restful/docs/conf.py
387index 59f6e02..e1cdf5d 100644
388--- a/src/lazr/restful/docs/conf.py
389+++ b/src/lazr/restful/docs/conf.py
390@@ -165,6 +165,3 @@ texinfo_documents = [
391 author, 'lazrrestful', 'One line description of project.',
392 'Miscellaneous'),
393 ]
394-
395-
396-
397diff --git a/src/lazr/restful/error.py b/src/lazr/restful/error.py
398index 059cd6a..389c2b8 100644
399--- a/src/lazr/restful/error.py
400+++ b/src/lazr/restful/error.py
401@@ -26,6 +26,7 @@ try:
402 from zope.app.exception.interfaces import ISystemErrorView
403 except ImportError:
404 from zope.interface import Interface
405+
406 class ISystemErrorView(Interface):
407 """Error views that can classify their contexts as system errors
408 """
409diff --git a/src/lazr/restful/example/base/filemanager.py b/src/lazr/restful/example/base/filemanager.py
410index 7b1120a..8e03049 100644
411--- a/src/lazr/restful/example/base/filemanager.py
412+++ b/src/lazr/restful/example/base/filemanager.py
413@@ -14,8 +14,8 @@ try:
414 import hashlib
415 sha_constructor = hashlib.sha1
416 except ImportError:
417- import sha
418- sha_constructor = sha.new
419+ import sha
420+ sha_constructor = sha.new
421
422 from zope.interface import implementer
423
424@@ -50,6 +50,8 @@ class FileManager:
425 """See `IFileManager`."""
426 if key in self.files:
427 del self.files[key]
428+
429+
430 grokcore.component.global_utility(FileManager)
431
432
433diff --git a/src/lazr/restful/example/base/root.py b/src/lazr/restful/example/base/root.py
434index c1a053d..197d5df 100644
435--- a/src/lazr/restful/example/base/root.py
436+++ b/src/lazr/restful/example/base/root.py
437@@ -34,7 +34,7 @@ from lazr.restful.testing.webservice import WebServiceTestPublication
438 from lazr.restful.utils import get_current_web_service_request
439
440
441-#Entry classes.
442+# Entry classes.
443 class CookbookWebServiceObject:
444 """A basic object published through the web service."""
445
446@@ -199,6 +199,7 @@ class Recipe(CookbookWebServiceObject):
447 def delete(self):
448 getUtility(IRecipeSet).removeRecipe(self)
449
450+
451 # Top-level objects.
452 @implementer(ILocation)
453 class CookbookTopLevelObject(CookbookWebServiceObject,
454@@ -338,6 +339,7 @@ def year(year):
455 """Turn a year into a datetime.date object."""
456 return date(year, 1, 1)
457
458+
459 C1 = Cookbook(u"Mastering the Art of French Cooking", "", Cuisine.FRANCAISE,
460 year(1961))
461 C2 = Cookbook(u"The Joy of Cooking", "", Cuisine.GENERAL, year(1995),
462@@ -379,8 +381,8 @@ class CookbookServiceRootResource(ServiceRootResource):
463 def top_level_names(self):
464 """Access or create the list of top-level objects."""
465 return {'cookbooks': getUtility(ICookbookSet),
466- 'dishes' : getUtility(IDishSet),
467- 'recipes' : getUtility(IRecipeSet),
468+ 'dishes': getUtility(IDishSet),
469+ 'recipes': getUtility(IRecipeSet),
470 'filemanager': getUtility(IFileManager)}
471
472 def get(self, name):
473@@ -388,8 +390,8 @@ class CookbookServiceRootResource(ServiceRootResource):
474 obj = self.top_level_names.get(name)
475 return obj
476
477-# Define the web service configuration.
478
479+# Define the web service configuration.
480 class WebServiceConfiguration(BaseWebServiceConfiguration):
481 directives.publication_class(WebServiceTestPublication)
482 caching_policy = [10000, 2]
483@@ -400,7 +402,7 @@ class WebServiceConfiguration(BaseWebServiceConfiguration):
484 active_versions = ['1.0', 'devel']
485 service_description = """<p>This is a web service.</p>
486 <p>It's got resources!</p>"""
487- version_descriptions = { 'devel' : """<p>The unstable development
488+ version_descriptions = {'devel': """<p>The unstable development
489 version.</p>
490
491 <p>Don't use this unless you like changing things.</p>"""
492@@ -409,4 +411,3 @@ class WebServiceConfiguration(BaseWebServiceConfiguration):
493 first_version_with_total_size_link = None
494 use_https = False
495 view_permission = 'lazr.restful.example.base.View'
496-
497diff --git a/src/lazr/restful/example/base/security.py b/src/lazr/restful/example/base/security.py
498index 7a1b85f..50354ba 100644
499--- a/src/lazr/restful/example/base/security.py
500+++ b/src/lazr/restful/example/base/security.py
501@@ -30,4 +30,3 @@ class CookbookWebServiceSecurityPolicy(PermissiveSecurityPolicy):
502 return False
503 else:
504 return True
505-
506diff --git a/src/lazr/restful/example/base/subscribers.py b/src/lazr/restful/example/base/subscribers.py
507index b2b0b1d..78daffe 100644
508--- a/src/lazr/restful/example/base/subscribers.py
509+++ b/src/lazr/restful/example/base/subscribers.py
510@@ -11,6 +11,7 @@ import grokcore.component
511 from lazr.lifecycle.interfaces import IObjectModifiedEvent
512 from lazr.restful.example.base.interfaces import ICookbook
513
514+
515 @grokcore.component.subscribe(ICookbook, IObjectModifiedEvent)
516 def update_cookbook_revision_number(object, event):
517 """Increment ICookbook.revision_number."""
518diff --git a/src/lazr/restful/example/base/tests/test_integration.py b/src/lazr/restful/example/base/tests/test_integration.py
519index d6de481..cec645d 100644
520--- a/src/lazr/restful/example/base/tests/test_integration.py
521+++ b/src/lazr/restful/example/base/tests/test_integration.py
522@@ -36,6 +36,8 @@ checker = renormalizing.OutputChecker()
523 class FunctionalLayer:
524 allow_teardown = False
525 zcml = os.path.abspath(resource_filename('lazr.restful', 'ftesting.zcml'))
526+
527+
528 zcml_layer(FunctionalLayer)
529
530
531@@ -43,6 +45,8 @@ class WSGILayer(FunctionalLayer):
532 @classmethod
533 def make_application(self):
534 return WebServiceApplication({}, CookbookWebServiceTestPublication)
535+
536+
537 wsgi_intercept_layer(WSGILayer)
538
539
540diff --git a/src/lazr/restful/example/base_extended/tests/test_integration.py b/src/lazr/restful/example/base_extended/tests/test_integration.py
541index 0732c8a..5235b28 100644
542--- a/src/lazr/restful/example/base_extended/tests/test_integration.py
543+++ b/src/lazr/restful/example/base_extended/tests/test_integration.py
544@@ -26,6 +26,8 @@ class FunctionalLayer:
545 allow_teardown = False
546 zcml = os.path.abspath(resource_filename(
547 'lazr.restful.example.base_extended', 'site.zcml'))
548+
549+
550 zcml_layer(FunctionalLayer)
551
552
553@@ -33,6 +35,8 @@ class WSGILayer(FunctionalLayer):
554 @classmethod
555 def make_application(self):
556 return WebServiceApplication({}, CookbookWebServiceTestPublication)
557+
558+
559 wsgi_intercept_layer(WSGILayer)
560
561
562diff --git a/src/lazr/restful/example/multiversion/resources.py b/src/lazr/restful/example/multiversion/resources.py
563index 693954d..bd1fb94 100644
564--- a/src/lazr/restful/example/multiversion/resources.py
565+++ b/src/lazr/restful/example/multiversion/resources.py
566@@ -45,6 +45,7 @@ class IKeyValuePair(ILocation):
567 deleted = exported(Bool(title=u"Whether this key-value pair has been "
568 "deleted"),
569 ('3.0', dict(exported=True)), exported=False)
570+
571 @mutator_for(a_comment)
572 @export_write_operation()
573 @operation_parameters(comment=Text())
574diff --git a/src/lazr/restful/example/multiversion/root.py b/src/lazr/restful/example/multiversion/root.py
575index 7447972..11452df 100644
576--- a/src/lazr/restful/example/multiversion/root.py
577+++ b/src/lazr/restful/example/multiversion/root.py
578@@ -58,4 +58,3 @@ class MultiversionWebServiceRootResource(RootResource):
579 ]
580 collections = dict(pairs=(IKeyValuePair, pairset))
581 return collections, {}
582-
583diff --git a/src/lazr/restful/example/multiversion/tests/test_integration.py b/src/lazr/restful/example/multiversion/tests/test_integration.py
584index dac7bbb..1c4e58b 100644
585--- a/src/lazr/restful/example/multiversion/tests/test_integration.py
586+++ b/src/lazr/restful/example/multiversion/tests/test_integration.py
587@@ -34,6 +34,8 @@ checker = renormalizing.OutputChecker()
588 class FunctionalLayer:
589 zcml = os.path.abspath(resource_filename(
590 'lazr.restful.example.multiversion', 'site.zcml'))
591+
592+
593 zcml_layer(FunctionalLayer)
594
595
596@@ -45,6 +47,8 @@ class WSGILayer(FunctionalLayer):
597 getUtility(IWebServiceConfiguration).port = None
598 root = MultiversionWebServiceRootResource()
599 return WebServiceApplication(root, Publication)
600+
601+
602 wsgi_intercept_layer(WSGILayer)
603
604
605diff --git a/src/lazr/restful/example/wsgi/root.py b/src/lazr/restful/example/wsgi/root.py
606index e8bca9e..277eb0c 100644
607--- a/src/lazr/restful/example/wsgi/root.py
608+++ b/src/lazr/restful/example/wsgi/root.py
609@@ -52,4 +52,3 @@ class WSGIExampleWebServiceRootResource(RootResource):
610 ]
611 collections = dict(pairs=(IKeyValuePair, pairset))
612 return collections, {}
613-
614diff --git a/src/lazr/restful/example/wsgi/tests/test_integration.py b/src/lazr/restful/example/wsgi/tests/test_integration.py
615index 87484b7..da2b911 100644
616--- a/src/lazr/restful/example/wsgi/tests/test_integration.py
617+++ b/src/lazr/restful/example/wsgi/tests/test_integration.py
618@@ -33,6 +33,8 @@ checker = renormalizing.OutputChecker()
619 class FunctionalLayer:
620 zcml = os.path.abspath(resource_filename(
621 'lazr.restful.example.wsgi', 'site.zcml'))
622+
623+
624 zcml_layer(FunctionalLayer)
625
626
627@@ -43,6 +45,8 @@ class WSGILayer(FunctionalLayer):
628 getUtility(IWebServiceConfiguration).port = None
629 root = WSGIExampleWebServiceRootResource()
630 return WebServiceApplication(root, Publication)
631+
632+
633 wsgi_intercept_layer(WSGILayer)
634
635
636diff --git a/src/lazr/restful/frameworks/django.py b/src/lazr/restful/frameworks/django.py
637index 8b6eeb8..d247e66 100644
638--- a/src/lazr/restful/frameworks/django.py
639+++ b/src/lazr/restful/frameworks/django.py
640@@ -51,6 +51,7 @@ class DjangoConfigurationGrokker(martian.ClassGrokker):
641 that can be overridden from your Django 'settings' module.
642 """
643 martian.component(DjangoWebServiceConfiguration)
644+
645 def execute(self, cls, config, *kw):
646 for name, field in getFieldsInOrder(IWebServiceConfiguration):
647 settings_name = "LAZR_RESTFUL_" + name.upper()
648@@ -76,6 +77,7 @@ class IDjangoLocation(Interface):
649 def __parent_object__(self):
650 """This object's parent in the object tree."""
651
652+
653 # We want a raised django.core.exceptions.ObjectDoesNotExist
654 # object to result in a 404 status code. But we don't
655 # control that class definition, so we can't annotate it.
656@@ -109,6 +111,8 @@ class DjangoLocation(object):
657 @property
658 def __name__(self):
659 return self.context.__url_path__
660+
661+
662 grokcore.component.global_adapter(DjangoLocation, IDjangoLocation, ILocation)
663
664
665@@ -135,4 +139,6 @@ class ManagerSequencer(object):
666 def __len__(self):
667 """Return the length of the dataset."""
668 return self.manager.count()
669+
670+
671 grokcore.component.global_adapter(ManagerSequencer, Manager, IFiniteSequence)
672diff --git a/src/lazr/restful/interface.py b/src/lazr/restful/interface.py
673index ce78b03..67971f1 100644
674--- a/src/lazr/restful/interface.py
675+++ b/src/lazr/restful/interface.py
676@@ -82,4 +82,3 @@ def copy_field(field, **overrides):
677 for name, value in overrides.items():
678 setattr(field_copy, name, value)
679 return field_copy
680-
681diff --git a/src/lazr/restful/interfaces/__init__.py b/src/lazr/restful/interfaces/__init__.py
682index 83a726a..de1611f 100644
683--- a/src/lazr/restful/interfaces/__init__.py
684+++ b/src/lazr/restful/interfaces/__init__.py
685@@ -27,9 +27,9 @@ try:
686 # While we generally frown on "*" imports, this approach, combined with
687 # the fact we only test code from this module, means that we can verify
688 # what has been exported in the local files (DRY).
689- from lazr.restful.interfaces._fields import *
690+ from lazr.restful.interfaces._fields import * # noqa: F401, F403
691 from lazr.restful.interfaces._fields import __all__ as _fields_all
692- from lazr.restful.interfaces._rest import *
693+ from lazr.restful.interfaces._rest import * # noqa: F401, F403
694 from lazr.restful.interfaces._rest import __all__ as _rest_all
695 __all__ = []
696 __all__.extend(_fields_all)
697diff --git a/src/lazr/restful/interfaces/_fields.py b/src/lazr/restful/interfaces/_fields.py
698index 7136a34..190df42 100644
699--- a/src/lazr/restful/interfaces/_fields.py
700+++ b/src/lazr/restful/interfaces/_fields.py
701@@ -36,6 +36,7 @@ class ICollectionField(ISequence):
702 All iterables satisfy this collection field.
703 """
704
705+
706 class IReference(IObject):
707 """A reference to an object providing a particular schema.
708
709diff --git a/src/lazr/restful/interfaces/_rest.py b/src/lazr/restful/interfaces/_rest.py
710index 158fd0a..3f37f26 100644
711--- a/src/lazr/restful/interfaces/_rest.py
712+++ b/src/lazr/restful/interfaces/_rest.py
713@@ -83,7 +83,7 @@ from zope.publisher.interfaces.browser import (
714 from lazr.batchnavigator.interfaces import InvalidBatchSizeError
715
716 # Constants for periods of time
717-HOUR = 3600 # seconds
718+HOUR = 3600 # seconds
719
720 # The namespace prefix for LAZR web service-related tags.
721 LAZR_WEBSERVICE_NS = 'lazr.restful'
722@@ -117,6 +117,7 @@ class IJSONPublishable(Interface):
723 may include parameters.
724 """
725
726+
727 class IServiceRootResource(IHTTPResource):
728 """A service root object that also acts as a resource."""
729
730@@ -309,6 +310,7 @@ class INotificationsProvider(Interface):
731 ERROR = logging.ERROR # the previous action did not succeed
732 """))
733
734+
735 class IWebServiceClientRequest(IBrowserRequest):
736 """Interface for requests to the web service."""
737 version = Attribute("The version of the web service that the client "
738@@ -331,6 +333,7 @@ class IWebServiceVersion(Interface):
739 """
740 pass
741
742+
743 class IJSONRequestCache(Interface):
744 """A cache of objects exposed as URLs or JSON representations."""
745
746diff --git a/src/lazr/restful/jsoncache.py b/src/lazr/restful/jsoncache.py
747index 9a08bdb..0c71d4d 100644
748--- a/src/lazr/restful/jsoncache.py
749+++ b/src/lazr/restful/jsoncache.py
750@@ -17,6 +17,7 @@ from zope.component import adapter
751 from zope.interface import implementer
752 from zope.publisher.interfaces import IApplicationRequest
753
754+
755 @implementer(IJSONRequestCache)
756 @adapter(IApplicationRequest)
757 class JSONRequestCache:
758diff --git a/src/lazr/restful/marshallers.py b/src/lazr/restful/marshallers.py
759index 21ca499..f212224 100644
760--- a/src/lazr/restful/marshallers.py
761+++ b/src/lazr/restful/marshallers.py
762@@ -185,7 +185,7 @@ class SimpleFieldMarshaller:
763 try:
764 v = value
765 if isinstance(v, bytes):
766- v = v.decode('utf8') # assume utf8
767+ v = v.decode('utf8') # assume utf8
768 elif not isinstance(v, six.text_type):
769 v = six.text_type(v)
770 value = simplejson.loads(v)
771diff --git a/src/lazr/restful/metazcml.py b/src/lazr/restful/metazcml.py
772index 680413a..95d5e4c 100644
773--- a/src/lazr/restful/metazcml.py
774+++ b/src/lazr/restful/metazcml.py
775@@ -67,6 +67,7 @@ def reset_globals():
776 del REGISTERED_OPERATIONS[:]
777 REGISTERED_CONTRIBUTORS.clear()
778
779+
780 try:
781 from zope.testing.cleanup import addCleanUp
782 except ImportError:
783@@ -329,6 +330,7 @@ def register_webservice(context, module):
784 callable=generate_and_register_webservice_operations,
785 order=2)
786
787+
788 @adapter(IProcessStarting)
789 def webservice_sanity_checks(registration):
790 """Ensure the web service contains no references to unpublished objects.
791@@ -390,7 +392,7 @@ def webservice_sanity_checks(registration):
792 version, referenced_interface, available_registrations,
793 "named operation %s returns %s" % (tags['as'], what))
794
795- if not 'params' in tags:
796+ if 'params' not in tags:
797 continue
798
799 for name, field in tags['params'].items():
800@@ -473,7 +475,7 @@ def generate_and_register_webservice_operations(
801 config.last_version_with_mutator_named_operations)
802 if len(config.active_versions) > no_mutator_operations_after+1:
803 block_mutator_operations_as_of_version = config.active_versions[
804- no_mutator_operations_after+1]
805+ no_mutator_operations_after + 1]
806 else:
807 block_mutator_operations_as_of_version = None
808 registered_adapters = set()
809@@ -569,7 +571,7 @@ def generate_and_register_webservice_operations(
810 else:
811 if tag['type'] == 'read_operation':
812 operation_provides = IResourceGETOperation
813- elif tag['type']in ['factory', 'write_operation']:
814+ elif tag['type'] in ['factory', 'write_operation']:
815 operation_provides = IResourcePOSTOperation
816 elif tag['type'] in ['destructor']:
817 operation_provides = IResourceDELETEOperation
818@@ -621,7 +623,7 @@ def generate_and_register_webservice_operations(
819 registered_adapters.add(
820 (operation_name, version, operation_provides))
821 if (tag.get('is_mutator')
822- and block_mutator_operations_as_of_version != None):
823+ and block_mutator_operations_as_of_version is not None):
824 defined_in = this_version_index
825 blocked_as_of = config.active_versions.index(
826 block_mutator_operations_as_of_version)
827@@ -672,5 +674,3 @@ def register_exception_view(context, exception):
828 WebServiceExceptionView, (exception, IWebServiceClientRequest),
829 Interface, 'index.html', context.info),
830 )
831-
832-
833diff --git a/src/lazr/restful/security.py b/src/lazr/restful/security.py
834index ff4530f..77ca653 100644
835--- a/src/lazr/restful/security.py
836+++ b/src/lazr/restful/security.py
837@@ -44,5 +44,3 @@ def protect_schema(type_, schema, read_permission=CheckerPublic,
838 continue
839 write_permissions[name] = write_permission
840 defineChecker(type_, Checker(read_permissions, write_permissions))
841-
842-
843diff --git a/src/lazr/restful/simple.py b/src/lazr/restful/simple.py
844index 25824e7..04c0a0a 100644
845--- a/src/lazr/restful/simple.py
846+++ b/src/lazr/restful/simple.py
847@@ -290,7 +290,6 @@ class RootResourceAbsoluteURL:
848 self.port = config.port
849 self.prefix = config.service_root_uri_prefix
850
851-
852 def __str__(self):
853 """Return the part of the URL that contains the hostname.
854
855@@ -502,4 +501,3 @@ class DictionaryBasedRepresentationCache(BaseRepresentationCache):
856 BaseWebServiceConfiguration = implement_from_dict(
857 "BaseWebServiceConfiguration", IWebServiceConfiguration,
858 {'first_version_with_total_size_link': None}, object)
859-
860diff --git a/src/lazr/restful/tales.py b/src/lazr/restful/tales.py
861index d9bb8df..7d12db9 100644
862--- a/src/lazr/restful/tales.py
863+++ b/src/lazr/restful/tales.py
864@@ -300,7 +300,7 @@ class WebLayerAPI:
865 def is_entry(self):
866 """Whether the object is published as an entry."""
867 request = get_current_web_service_request()
868- return queryMultiAdapter((self.context, request), IEntry) != None
869+ return queryMultiAdapter((self.context, request), IEntry) is not None
870
871 @property
872 def json(self):
873@@ -740,7 +740,6 @@ class WadlFieldAPI(RESTUtilityBase):
874 % (self.field.interface, self.field.getName()))
875 raise e
876
877-
878 @property
879 def options(self):
880 """An enumeration of acceptable values for this field.
881diff --git a/src/lazr/restful/testing/event.py b/src/lazr/restful/testing/event.py
882index d071af5..3eaf040 100644
883--- a/src/lazr/restful/testing/event.py
884+++ b/src/lazr/restful/testing/event.py
885@@ -36,4 +36,3 @@ class TestEventListener:
886 sm = zope.component.getGlobalSiteManager()
887 sm.unregisterHandler(
888 self, (self.object_type, self.event_type))
889-
890diff --git a/src/lazr/restful/testing/tales.py b/src/lazr/restful/testing/tales.py
891index 616502f..b8afdb3 100644
892--- a/src/lazr/restful/testing/tales.py
893+++ b/src/lazr/restful/testing/tales.py
894@@ -33,4 +33,3 @@ def test_tales(expression, **kw):
895 # fail if an object is accessed or imported outside of page's namespace.
896 compiled_tales = TrustedEngine.compile(expression)
897 return compiled_tales(Context(**kw))
898-
899diff --git a/src/lazr/restful/testing/webservice.py b/src/lazr/restful/testing/webservice.py
900index ec621e4..be79781 100644
901--- a/src/lazr/restful/testing/webservice.py
902+++ b/src/lazr/restful/testing/webservice.py
903@@ -156,7 +156,6 @@ class FakeRequest:
904 self.URL = 'http://api.example.org/'
905 self.headers = {}
906
907-
908 def getTraversalStack(self):
909 """See `IPublicationRequest`.
910
911diff --git a/src/lazr/restful/tests/test_declarations.py b/src/lazr/restful/tests/test_declarations.py
912index 6a693e4..12d380c 100644
913--- a/src/lazr/restful/tests/test_declarations.py
914+++ b/src/lazr/restful/tests/test_declarations.py
915@@ -228,10 +228,14 @@ class ContributingInterfacesTestCase(TestCaseWithWebServiceFixtures):
916 self.product._bug_count = 10
917 self.project._bug_count = 100
918 register_test_module('testmod', IProduct, IProject, IHasBugs)
919- adapter = getMultiAdapter((self.product, self.one_zero_request), IEntry)
920+ adapter = getMultiAdapter(
921+ (self.product, self.one_zero_request), IEntry
922+ )
923 self.assertEqual(adapter.bug_count, 10)
924
925- adapter = getMultiAdapter((self.project, self.one_zero_request), IEntry)
926+ adapter = getMultiAdapter(
927+ (self.project, self.one_zero_request), IEntry
928+ )
929 self.assertEqual(adapter.bug_count, 100)
930
931 def test_multiple_contributing_interfaces(self):
932@@ -241,7 +245,9 @@ class ContributingInterfacesTestCase(TestCaseWithWebServiceFixtures):
933 self.product._dev_branch = Branch('A product branch')
934 register_test_module(
935 'testmod', IBranch, IProduct, IHasBugs, IHasBranches)
936- adapter = getMultiAdapter((self.product, self.one_zero_request), IEntry)
937+ adapter = getMultiAdapter(
938+ (self.product, self.one_zero_request), IEntry
939+ )
940 self.assertEqual(adapter.bug_count, 10)
941 self.assertEqual(adapter.development_branch, self.product._dev_branch)
942
943@@ -251,6 +257,7 @@ class ContributingInterfacesTestCase(TestCaseWithWebServiceFixtures):
944 @exported_as_webservice_entry()
945 class IEmpty(Interface):
946 pass
947+
948 @implementer(IEmpty)
949 class Empty:
950 pass
951@@ -279,7 +286,8 @@ class ContributingInterfacesTestCase(TestCaseWithWebServiceFixtures):
952 secure_product = ProxyFactory(
953 self.product,
954 checker=MultiChecker([(IProduct, 'zope.Public')]))
955- entry_resource = EntryResource(secure_product, self.one_zero_request)
956+ entry_resource = EntryResource(
957+ secure_product, self.one_zero_request)
958 self.assertEqual([], entry_resource.redacted_fields)
959 finally:
960 endInteraction()
961@@ -308,6 +316,7 @@ class ContributingInterfacesTestCase(TestCaseWithWebServiceFixtures):
962 # A contributing interface can only contribute to exported interfaces.
963 class INotExported(Interface):
964 pass
965+
966 @exported_as_webservice_entry(contributes_to=[INotExported])
967 class IContributor(Interface):
968 title = exported(TextLine(title=u'The project title'))
969@@ -336,7 +345,9 @@ class ContributingInterfacesTestCase(TestCaseWithWebServiceFixtures):
970 # different adapters, its type name is that of the main interface and
971 # not one of its contributors.
972 register_test_module('testmod', IProduct, IHasBugs)
973- adapter = getMultiAdapter((self.product, self.one_zero_request), IEntry)
974+ adapter = getMultiAdapter(
975+ (self.product, self.one_zero_request), IEntry
976+ )
977 self.assertEqual(
978 'product', EntryAdapterUtility(adapter.__class__).singular_type)
979
980@@ -805,7 +816,6 @@ class TestEntryMultiversion(TestCaseWithWebServiceFixtures):
981 INotPresentInLaterVersion, [],
982 *getUtility(IWebServiceConfiguration).active_versions)
983 self.assertEqual(len(interfaces), 1)
984- tags = interfaces[0][1].getTaggedValue(LAZR_WEBSERVICE_NAME)
985 self.assertEqual(interfaces[0].version, '1.0')
986
987 def test_different_names_in_different_versions(self):
988@@ -971,8 +981,7 @@ class TestRequireExplicitVersions(TestCaseWithWebServiceFixtures):
989 'but not by using as_of. The service configuration requires '
990 'that you use as_of.')
991
992-
993- def test_field_exported_as_of_earlier_version_is_exported_in_subsequent_versions(self):
994+ def test_field_exported_as_of_earlier_version_is_exported_in_subsequent_versions(self): # noqa: E501
995 # If you export a field as_of version 1.0, it's present in
996 # 1.0's version of the entry and in all subsequent versions.
997 interfaces = generate_entry_interfaces(
998@@ -983,7 +992,7 @@ class TestRequireExplicitVersions(TestCaseWithWebServiceFixtures):
999 self.assertEqual(list(interface_10.names()), ['field'])
1000 self.assertEqual(list(interface_20.names()), ['field'])
1001
1002- def test_field_exported_as_of_later_version_is_not_exported_in_earlier_versions(self):
1003+ def test_field_exported_as_of_later_version_is_not_exported_in_earlier_versions(self): # noqa: E501
1004 # If you export a field as_of version 2.0, it's not present in
1005 # 1.0's version of the entry.
1006 interfaces = generate_entry_interfaces(
1007@@ -1188,7 +1197,7 @@ class TestSanityChecking(TestCaseWithWebServiceFixtures):
1008
1009 def _test_fails_sanity_check(
1010 self, expect_failure_in_version, expect_failure_for_reason,
1011- expect_failure_due_to_interface, *classes):
1012+ expect_failure_due_to_interface, *classes):
1013 """Verify that the given interfaces can't become a web service.
1014
1015 The given set of interfaces are expected to fail the sanity
1016@@ -1213,13 +1222,12 @@ class TestSanityChecking(TestCaseWithWebServiceFixtures):
1017 expected_message = (
1018 "In version %(version)s, %(reason)s, but version %(version)s "
1019 "of the web service does not publish %(interface)s as an entry. "
1020- "(It may not be published at all.)" % dict(
1021+ "(It may not be published at all.)" % dict(
1022 version=expect_failure_in_version,
1023 reason=expect_failure_for_reason,
1024 interface=expect_failure_due_to_interface.__name__))
1025 self.assertEqual(str(exception), expected_message)
1026
1027-
1028 def test_reference_to_unpublished_object_fails(self):
1029 self._test_fails_sanity_check(
1030 '1.0',
1031diff --git a/src/lazr/restful/tests/test_utils.py b/src/lazr/restful/tests/test_utils.py
1032index c70c90b..91dbc8e 100644
1033--- a/src/lazr/restful/tests/test_utils.py
1034+++ b/src/lazr/restful/tests/test_utils.py
1035@@ -119,7 +119,7 @@ class TestVersionedDict(testtools.TestCase):
1036 self.assertRaises(
1037 KeyError, self.dict.rename_version, "not present", "renamed")
1038
1039- def test_dict_for_name_finds_first_dict(self):
1040+ def test_dict_for_name_finds_dict_with_given_name(self):
1041 # dict_for_name finds a dict with the given name in the stack.
1042 self.dict.push("name1")
1043 self.dict['key'] = 'value1'
1044@@ -204,7 +204,6 @@ class TestVersionedDict(testtools.TestCase):
1045 'Error test: Unrecognized version "nosuchversion".')
1046
1047
1048-
1049 class TestParseAcceptStyleHeader(unittest.TestCase):
1050
1051 def test_single_value(self):
1052diff --git a/src/lazr/restful/tests/test_webservice.py b/src/lazr/restful/tests/test_webservice.py
1053index bf43319..acb4ae0 100644
1054--- a/src/lazr/restful/tests/test_webservice.py
1055+++ b/src/lazr/restful/tests/test_webservice.py
1056@@ -161,7 +161,7 @@ class EntryTestCase(WebServiceTestCase):
1057 def request(self, media_type=None):
1058 media_type = media_type or self.default_media_type
1059 request = getUtility(IWebServiceConfiguration).createRequest(
1060- BytesIO(b""), {'HTTP_ACCEPT' : media_type})
1061+ BytesIO(b""), {'HTTP_ACCEPT': media_type})
1062 newInteraction(request)
1063 yield request
1064 endInteraction()
1065@@ -180,7 +180,8 @@ class EntryTestCase(WebServiceTestCase):
1066 data_object = entry_implementation(*implementation_args)
1067
1068 with self.request() as request:
1069- entry = entry_class(data_object, request)
1070+ # todo: needs a closer look
1071+ entry = entry_class(data_object, request) # noqa: F841
1072 resource = EntryResource(data_object, request)
1073 yield resource
1074
1075@@ -722,7 +723,7 @@ class WadlAPITestCase(WebServiceTestCase):
1076 'A simple collection containing IGenericEntry, for use in tests.',
1077 '</wadl:doc>'], doclines)
1078
1079- def test_field_wadl_doc (self):
1080+ def test_field_wadl_doc(self):
1081 """Test the wadl:doc generated for an exported field."""
1082 entry = get_resource_factory(IGenericEntry, IEntry)
1083 field = entry.schema['a_field']
1084@@ -750,7 +751,7 @@ class WadlAPITestCase(WebServiceTestCase):
1085 # we dont care about the formatting of the parameters table.
1086 self.assertEqual([
1087 '<wadl:doc xmlns="http://www.w3.org/1999/xhtml">',
1088- '<p>Print an appropriate greeting based on the message.</p>',],
1089+ '<p>Print an appropriate greeting based on the message.</p>', ],
1090 doclines[0:2])
1091 self.assertEqual('</wadl:doc>', doclines[-1])
1092 self.assertTrue(len(doclines) > 3,
1093@@ -939,7 +940,6 @@ class BaseBatchingTest:
1094 LAZR_WEBSERVICE_NAME,
1095 dict(singular='test_entity', plural='test_entities'))
1096
1097-
1098 def make_instance(self, entries, request):
1099 raise NotImplementedError('You have to make your own instances.')
1100
1101@@ -1000,6 +1000,7 @@ class NotificationsProviderTest(EntryTestCase):
1102 return [Notification(logging.INFO, "Informational"),
1103 Notification(logging.WARNING, "Warning")
1104 ]
1105+
1106 def setUp(self):
1107 super(NotificationsProviderTest, self).setUp()
1108 self.default_media_type = "application/json;include=lp_html"
1109@@ -1037,6 +1038,7 @@ class NotificationsProviderTest(EntryTestCase):
1110 [logging.INFO, "Informational"], [logging.WARNING, "Warning"]]
1111 self.assertEqual(notifications, expected_notifications)
1112
1113+
1114 class EventTestCase(EntryTestCase):
1115
1116 testmodule_objects = [IHasOneField]
1117diff --git a/src/lazr/restful/wsgi.py b/src/lazr/restful/wsgi.py
1118index 56593dd..5006d1a 100644
1119--- a/src/lazr/restful/wsgi.py
1120+++ b/src/lazr/restful/wsgi.py
1121@@ -71,4 +71,3 @@ class BaseWSGIWebServiceConfiguration(BaseWebServiceConfiguration):
1122 WebServiceConfiguration. It's only maintained for backwards
1123 compatibility.
1124 """
1125-
1126diff --git a/tox.ini b/tox.ini
1127index aac9737..02b7f78 100644
1128--- a/tox.ini
1129+++ b/tox.ini
1130@@ -15,3 +15,33 @@ deps =
1131 .[docs]
1132 commands =
1133 sphinx-build -b html -d src/lazr/restful/docs/_build/doctrees src/lazr/restful/docs src/lazr/restful/docs/_build/html
1134+
1135+[flake8]
1136+ignore =
1137+ # most errors from the E section will be fixed by using black
1138+ E121
1139+ E123
1140+ E124
1141+ E125
1142+ E126
1143+ E127
1144+ E128
1145+ E129
1146+ E131
1147+ E201
1148+ E202
1149+ E203
1150+ E225
1151+ E226
1152+ E231
1153+ E251
1154+ E261
1155+ E402
1156+ E501
1157+ # W503 and W504 are mutually exclusive
1158+ W503
1159+ W504
1160+ # todo
1161+ E731
1162+ F821
1163+ W605

Subscribers

People subscribed via source and target branches