Skip to content

Commit

Permalink
Apply pre-commit code formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci-lite[bot] authored Aug 16, 2024
1 parent 6c99bff commit 97d112b
Show file tree
Hide file tree
Showing 28 changed files with 47 additions and 10 deletions.
2 changes: 2 additions & 0 deletions src/App/Dialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@
class MessageDialogHTML(HTML):
"""A special version of HTML which is always published as text/html
"""

def __call__(self, *args, **kw):
class _HTMLString(str):
"""A special string that will be published as text/html
"""

def asHTML(self):
return self
return _HTMLString(super().__call__(*args, **kw))
Expand Down
1 change: 1 addition & 0 deletions src/App/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class DefaultConfiguration:
"""
This configuration should be used effectively only during unit tests
"""

def __init__(self):
from App import FindHomes
self.clienthome = FindHomes.CLIENT_HOME
Expand Down
1 change: 1 addition & 0 deletions src/App/tests/test_ProductContext.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ def _verify_reg(self, name, obj):

class _Product:
"""Product mockup."""

def __init__(self):
self.id = "pid"

Expand Down
4 changes: 2 additions & 2 deletions src/OFS/DTMLDocument.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ class DTMLDocument(PropertyManager, DTMLMethod):

# Replace change_dtml_methods by change_dtml_documents
__ac_permissions__ = tuple([
(perms[0] == change_dtml_methods) and # NOQA: W504
(change_dtml_documents, perms[1]) or perms
(perms[0] == change_dtml_methods) # NOQA: W504
and (change_dtml_documents, perms[1]) or perms
for perms in DTMLMethod.__ac_permissions__])

def __call__(self, client=None, REQUEST={}, RESPONSE=None, **kw):
Expand Down
1 change: 1 addition & 0 deletions src/OFS/absoluteurl.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ def _isVirtualHostRoot(self):
class RootAbsoluteURL(OFSTraversableAbsoluteURL):
"""An absolute_url adapter for the root object (OFS.Application)
"""

def breadcrumbs(self):
context = self.context

Expand Down
1 change: 1 addition & 0 deletions src/OFS/tests/testHistory.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ def test_manage_historicalComparison(self):
class HistoryItemWithSetState(HistoryItem):
"""A class with a data migration on __setstate__
"""

def __setstate__(self, state):
super().__setstate__(state)
self.changed_something = True
Expand Down
1 change: 1 addition & 0 deletions src/OFS/tests/testObjectManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,7 @@ def test_export_import(self):

class _CallResult:
"""Auxiliary class to provide defined call results."""

def __init__(self, result):
self.result = result

Expand Down
6 changes: 6 additions & 0 deletions src/OFS/tests/testTraverse.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class UnitTestSecurityPolicy:
Stub out the existing security policy for unit testing purposes.
"""
# Standard SecurityPolicy interface

def validate(self, accessed=None, container=None, name=None, value=None,
context=None, roles=None, *args, **kw):
return 1
Expand All @@ -33,6 +34,7 @@ class CruelSecurityPolicy:
"""Denies everything
"""
# Standard SecurityPolicy interface

def validate(self, accessed, container, name, value, *args):
from AccessControl import Unauthorized
raise Unauthorized(name)
Expand All @@ -44,6 +46,7 @@ def checkPermission(self, permission, object, context):
class ProtectedMethodSecurityPolicy:
"""Check security strictly on bound methods.
"""

def validate(self, accessed, container, name, value, *args):
from AccessControl import Unauthorized
from Acquisition import aq_base
Expand Down Expand Up @@ -135,6 +138,7 @@ class UnitTestUser(Implicit):
"""
Stubbed out manager for unit testing purposes.
"""

def getId(self):
return 'unit_tester'
getUserName = getId
Expand Down Expand Up @@ -192,10 +196,12 @@ class Restricted(SimpleItem):
"""Instance we'll check with ProtectedMethodSecurityPolicy."""

getId__roles__ = None # ACCESS_PUBLIC

def getId(self): # NOQA: E306 # pseudo decorator
return self.id

private__roles__ = () # ACCESS_PRIVATE

def private(self): # NOQA: E306 # pseudo decorator
return 'private!'

Expand Down
1 change: 1 addition & 0 deletions src/Products/Five/browser/pagetemplatefile.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def getEngine():
class ViewPageTemplateFile(TrustedAppPT, PageTemplateFile):
"""Page Template used as class variable of views defined as Python classes.
"""

def __init__(self, filename, _prefix=None, content_type=None):
_prefix = self.get_path_from_prefix(_prefix)
super().__init__(filename, _prefix)
Expand Down
1 change: 1 addition & 0 deletions src/Products/Five/browser/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class Resource:
thus making this mixin (and probably the other classes in this
module) obsolete.
"""

def __call__(self):
name = self.__name__
container = self.__parent__
Expand Down
1 change: 1 addition & 0 deletions src/Products/Five/tests/testing/folder.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class NoVerifyPasteFolder(Folder):
"""Folder that does not perform paste verification.
Used by test_events
"""

def _verifyObjectPaste(self, object, validate_src=1):
pass

Expand Down
1 change: 1 addition & 0 deletions src/Products/Five/viewlet/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class UnitTestSecurityPolicy:
Stub out the existing security policy for unit testing purposes.
"""
# Standard SecurityPolicy interface

def validate(self,
accessed=None,
container=None,
Expand Down
1 change: 1 addition & 0 deletions src/Products/PageTemplates/Expressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ class _CombinedMapping:
Earlier mappings take precedence.
"""

def __init__(self, *ms):
self.mappings = ms

Expand Down
3 changes: 3 additions & 0 deletions src/Products/PageTemplates/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ def __call__(self, key, iterable):

class RepeatItem(PathIterator):
"""Iterator compatible with ``chameleon`` and ``zope.tales``."""

def __iter__(self):
return self

Expand Down Expand Up @@ -241,6 +242,7 @@ def _C2ZContextWrapper(c_context, attrs):

class MappedExpr:
"""map expression: ``zope.tales`` --> ``chameleon.tales``."""

def __init__(self, type, expression, zt_engine):
self.type = type
# At this place, *expression* is a `chameleon.tokenize.Token`
Expand Down Expand Up @@ -315,6 +317,7 @@ def __call__(self, target, c_engine):

class MappedExprType:
"""map expression type: ``zope.tales`` --> ``chameleon.tales``."""

def __init__(self, engine, type):
self.engine = engine
self.type = type
Expand Down
1 change: 1 addition & 0 deletions src/Products/PageTemplates/expression.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ class ChameleonEngine(ExpressionEngine):
Only partially implemented: its ``compile`` is currently unusable
"""

def compile(self, expression):
raise NotImplementedError()

Expand Down
1 change: 1 addition & 0 deletions src/Products/PageTemplates/tests/testDTMLTests.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class UnitTestSecurityPolicy:
#
# Standard SecurityPolicy interface
#

def validate(self,
accessed=None,
container=None,
Expand Down
1 change: 1 addition & 0 deletions src/Products/PageTemplates/tests/testHTMLTests.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class UnitTestSecurityPolicy:
Stub out the existing security policy for unit testing purposes.
"""
# Standard SecurityPolicy interface

def validate(self,
accessed=None,
container=None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class ZopeTalesExpressionTests(testHTMLTests.HTMLTests):
The tests in this class ensure that the ``_zt_expr_registry``
is cleared at the start and end of each test.
"""

def setUp(self):
super().setUp()
_zt_expr_registry.clear()
Expand Down
8 changes: 4 additions & 4 deletions src/Shared/DC/Scripts/Signature.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ def __init__(self, varnames=(), argcount=-1):
def __eq__(self, other):
if not isinstance(other, FuncCode):
return False
return ((self.co_argcount, self.co_varnames) == # NOQA: W504
(other.co_argcount, other.co_varnames))
return ((self.co_argcount, self.co_varnames) # NOQA: W504
== (other.co_argcount, other.co_varnames))

def __lt__(self, other):
if not isinstance(other, FuncCode):
return False
return ((self.co_argcount, self.co_varnames) < # NOQA: W504
(other.co_argcount, other.co_varnames))
return ((self.co_argcount, self.co_varnames) # NOQA: W504
< (other.co_argcount, other.co_varnames))


def _setFuncSignature(self, defaults=None, varnames=(), argcount=-1):
Expand Down
4 changes: 2 additions & 2 deletions src/ZPublisher/BaseRequest.py
Original file line number Diff line number Diff line change
Expand Up @@ -849,11 +849,11 @@ def lineno(o, m=False):
f = i.unwrap(obj.__func__)
c = obj.__self__.__class__
desc = f"'{c.__module__}.{c.__qualname__}' " \
f"method '{obj.__qualname__}'{lineno(f, 1)}"
f"method '{obj.__qualname__}'{lineno(f, 1)}"
elif i.isfunction(obj):
f = i.unwrap(obj)
desc = f"function '{f.__module__}.{f.__qualname__}'" \
f"{lineno(f)}"
f"{lineno(f)}"
else:
try:
cls_doc = "__doc__" not in obj.__dict__
Expand Down
1 change: 1 addition & 0 deletions src/ZPublisher/BeforeTraverse.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ class MultiHook:
MultiHook calls the named hook from the class of the container, then
the prior hook, then all the hooks in its list.
"""

def __init__(self, hookname='<undefined hookname>', prior=None,
defined_in_class=False):
# The default values are needed for unpickling instances of this class
Expand Down
4 changes: 3 additions & 1 deletion src/ZPublisher/HTTPRequest.py
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ def processInputs(
elif has_codec(type_name):
# recode:
assert not isinstance(item, FileUpload), \
"cannot recode files"
"cannot recode files"
item = item.encode(
character_encoding, "surrogateescape")
character_encoding = type_name
Expand Down Expand Up @@ -1354,6 +1354,7 @@ def sane_environment(env):

class ValueDescriptor:
"""(non data) descriptor to compute `value` from `file`."""

def __get__(self, inst, owner=None):
if inst is None:
return self
Expand Down Expand Up @@ -1381,6 +1382,7 @@ def __get__(self, inst, owner=None):

class Global:
"""(non data) descriptor to access a (modul) global attribute."""

def __init__(self, name):
"""access global *name*."""
self.name = name
Expand Down
1 change: 1 addition & 0 deletions src/ZPublisher/cookie.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ class CookieParameterRegistry:
It maintains 2 maps: one to normalize parameter names
and one to check and convert parameter values.
"""

def __init__(self):
self._normalize = {}
self._convert = {}
Expand Down
2 changes: 2 additions & 0 deletions src/ZPublisher/tests/testBaseRequest.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ def __before_publishing_traverse__(self, object, REQUEST):
def _makeObjectWithBD(self):
class DummyObjectWithBD(self._makeBasicObjectClass()):
"""Dummy class with __browser_default__."""

def __browser_default__(self, REQUEST):
if REQUEST['_test_counter'] < 100:
REQUEST['_test_counter'] += 1
Expand All @@ -155,6 +156,7 @@ def _makeObjectWithBBT(self):
@zpublish
class _DummyResult:
''' '''

def __init__(self, tag):
self.tag = tag

Expand Down
2 changes: 2 additions & 0 deletions src/ZPublisher/tests/testHTTPRequest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1565,6 +1565,7 @@ class TestSearchType(unittest.TestCase):
see "https://github.com/zopefoundation/Zope/pull/512"
"""

def check(self, val, expect):
mo = search_type(val)
if expect is None:
Expand All @@ -1590,6 +1591,7 @@ def test_special(self):

class _Unseekable:
"""Auxiliary class emulating an unseekable file like object"""

def __init__(self, file):
for m in ("read", "readline", "close", "__del__"):
setattr(self, m, getattr(file, m))
Expand Down
1 change: 1 addition & 0 deletions src/webdav/xmltools.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ def toxml(self):
class ProtectedExpatParser(ExpatParser):
""" See https://bugs.launchpad.net/zope2/+bug/1114688
"""

def __init__(self, forbid_dtd=True, forbid_entities=True,
*args, **kwargs):
# Python 2.x old style class
Expand Down
1 change: 1 addition & 0 deletions src/zmi/styles/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def afterSetUp(self):

def call_manage_main(self):
"""Call /folder/manage_main and return the HTML text."""

def _call_manage_main(self):
self.setRoles(['Manager'])
# temporaryPlacelessSetUp insists in creating an interaction
Expand Down
4 changes: 3 additions & 1 deletion util.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import os
from typing import Optional, Tuple, List
from configparser import NoSectionError
from configparser import RawConfigParser
from typing import List
from typing import Optional
from typing import Tuple


HERE = os.path.abspath(os.path.dirname(__file__))
Expand Down

0 comments on commit 97d112b

Please sign in to comment.