Skip to content

Commit

Permalink
style(lint): Cleanup/ignore common linter errors
Browse files Browse the repository at this point in the history
These are linters that my editor uses by default because they are common linters, so
might as well fix what we can and ignore the rest.  As much as possible, I placed
ignores that should apply across the code base in the appropriate configuration file
rather than inline comments.
  • Loading branch information
rpatterson committed Feb 14, 2022
1 parent 7e6d9d5 commit 660343d
Show file tree
Hide file tree
Showing 10 changed files with 75 additions and 6 deletions.
45 changes: 45 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Couldn't get `foo.*` module wildcards to work in `./pyproject.toml`
[mypy-ordereddict]
ignore_missing_imports = True
[mypy-transaction]
ignore_missing_imports = True
[mypy-zope.*]
ignore_missing_imports = True
[mypy-ZODB.*]
ignore_missing_imports = True
[mypy-BTrees.*]
ignore_missing_imports = True
[mypy-zExceptions.*]
ignore_missing_imports = True
[mypy-AccessControl.*]
ignore_missing_imports = True
[mypy-Acquisition.*]
ignore_missing_imports = True
[mypy-OFS.*]
ignore_missing_imports = TRUE
[mypy-ZPublisher.*]
ignore_missing_imports = True
[mypy-App.*]
ignore_missing_imports = True
[mypy-AuthEncoding.*]
ignore_missing_imports = True
[mypy-DateTime.*]
ignore_missing_imports = True
[mypy-Products.*]
ignore_missing_imports = True
[mypy-plone.*]
ignore_missing_imports = True

# For some reason installing `types-*` didn't work
[mypy-six.*]
ignore_missing_imports = True
[mypy-past.*]
ignore_missing_imports = True
[mypy-PIL.*]
ignore_missing_imports = True

# Zope interfaces break MyPy expectations and unfortunately I couldn't find a way to
# ignore only the specific error MyPy reports:
# `./src/Products/PlonePAS/interfaces/capabilities.py:57: error: Method must have at least one argument`
[mypy-*.interfaces.*]
ignore_errors = True
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
[tool.pylint.'MESSAGES CONTROL']
disable = [
"wrong-import-order",
]

[tool.towncrier]
filename = "CHANGES.rst"
directory = "news/"
Expand Down
8 changes: 8 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,11 @@ create-wheel = yes
# When Python 2-3 compatible:
[bdist_wheel]
universal = 1

[flake8]
# Match Black's defaults
# https://black.readthedocs.io/en/stable/guides/using_black_with_other_tools.html#flake8
max-line-length = 88
extend-ignore = E203
aggressive = 3
experimental = true
2 changes: 1 addition & 1 deletion src/Products/PlonePAS/interfaces/memberdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ class IMemberDataTool(interfaces.IMemberDataTool):
"""


__all__ = (IMemberDataTool,)
__all__ = ("IMemberDataTool", )
2 changes: 1 addition & 1 deletion src/Products/PlonePAS/interfaces/membership.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ def getMemberInfo(memberId=None):
location, etc
"""

__all__ = (IMembershipTool, )
__all__ = ("IMembershipTool", )
2 changes: 1 addition & 1 deletion src/Products/PlonePAS/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def call(self, __name__, *args, **kw):
ADDED = '__PlonePAS_is_added_method__'
ORIG_NAME = '__PlonePAS_original_method_name__'

_marker = dict()
_marker = dict() # type: ignore


def isWrapperMethod(meth):
Expand Down
2 changes: 1 addition & 1 deletion src/Products/PlonePAS/plugins/ufactory.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
try:
from collections import OrderedDict
except ImportError:
from ordereddict import OrderedDict
from ordereddict import OrderedDict # type: ignore

manage_addPloneUserFactoryForm = DTMLFile('../zmi/PloneUserFactoryForm',
globals())
Expand Down
2 changes: 2 additions & 0 deletions src/Products/PlonePAS/sheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from Products.CMFCore.interfaces import ISiteRoot
from Products.PlonePAS.interfaces.propertysheets import IMutablePropertySheet
from Products.PluggableAuthService.UserPropertySheet import UserPropertySheet
from past.builtins import long
from zope.component import getUtility
from zope.interface import implementer

Expand Down Expand Up @@ -42,6 +43,7 @@ def validate(self, property_type, value):
inspector = self.tmap[property_type]
return inspector(value)


PropertySchema = PropertySchemaTypeMap()
PropertySchema.addType(
'string',
Expand Down
11 changes: 10 additions & 1 deletion src/Products/PlonePAS/tests/test_setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# -*- coding: utf-8 -*-
"""
Test set up specific to Plone through thea GenericSetup profile installation.
"""

from plone.app import testing as pa_testing
from plone.testing import zope
from zope.component import hooks
Expand All @@ -13,6 +17,9 @@


class PortalSetupTest(unittest.TestCase):
"""
Test set up specific to Plone through thea GenericSetup profile installation.
"""

layer = testing.PRODUCTS_PLONEPAS_FUNCTIONAL_TESTING

Expand Down Expand Up @@ -116,7 +123,9 @@ def test_zope_root_default_login(self):
# Submit the login form in the browser
login_form = browser.getForm()
login_form.getControl(name="__ac_name").value = pa_testing.SITE_OWNER_NAME
login_form.getControl(name="__ac_password").value = pa_testing.TEST_USER_PASSWORD
login_form.getControl(
name="__ac_password"
).value = pa_testing.TEST_USER_PASSWORD
login_form.controls[-1].click()
self.assertEqual(
browser.headers["Status"].lower(),
Expand Down
2 changes: 1 addition & 1 deletion src/Products/PlonePAS/tools/membership.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
default_portrait = 'defaultUser.png'
logger = logging.getLogger('PlonePAS')

_marker = dict()
_marker = dict() # type: ignore


def _unicodify_structure(value, charset=_marker):
Expand Down

0 comments on commit 660343d

Please sign in to comment.