Merge ~jugmac00/launchpadlib:flake8-code into launchpadlib:main

Proposed by Jürgen Gmach
Status: Merged
Merge reported by: Jürgen Gmach
Merged at revision: 1effcf41eb84cd394e6a39aa8fd030de30aa3c1d
Proposed branch: ~jugmac00/launchpadlib:flake8-code
Merge into: launchpadlib:main
Diff against target: 305 lines (+47/-26)
13 files modified
.pre-commit-config.yaml (+7/-0)
setup.cfg (+14/-0)
setup.py (+4/-2)
src/launchpadlib/apps.py (+0/-2)
src/launchpadlib/bin/launchpad-request-token (+3/-1)
src/launchpadlib/credentials.py (+7/-7)
src/launchpadlib/docs/conf.py (+0/-3)
src/launchpadlib/errors.py (+1/-1)
src/launchpadlib/launchpad.py (+4/-5)
src/launchpadlib/testing/helpers.py (+2/-2)
src/launchpadlib/tests/test_credential_store.py (+1/-1)
src/launchpadlib/tests/test_launchpad.py (+2/-0)
src/launchpadlib/uris.py (+2/-2)
Reviewer Review Type Date Requested Status
Colin Watson (community) Approve
Review via email: mp+410890@code.launchpad.net

Commit message

Use flake8 via pre-commit

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
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 015c36c..8ef0d2f 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -1,5 +1,7 @@
1# See https://pre-commit.com for more information1# See https://pre-commit.com for more information
2# See https://pre-commit.com/hooks.html for more hooks2# See https://pre-commit.com/hooks.html for more hooks
3exclude: ^contrib/
4
3repos:5repos:
4- repo: https://github.com/pre-commit/pre-commit-hooks6- repo: https://github.com/pre-commit/pre-commit-hooks
5 rev: v3.2.07 rev: v3.2.0
@@ -8,3 +10,8 @@ repos:
8 - id: check-merge-conflict10 - id: check-merge-conflict
9 - id: check-xml11 - id: check-xml
10 - id: check-yaml12 - id: check-yaml
13 - id: debug-statements
14- repo: https://github.com/PyCQA/flake8
15 rev: 3.9.2
16 hooks:
17 - id: flake8
diff --git a/setup.cfg b/setup.cfg
index 2a9acf1..121ec76 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,2 +1,16 @@
1[bdist_wheel]1[bdist_wheel]
2universal = 12universal = 1
3
4[flake8]
5ignore =
6 # indentation / whitespace issues -> will be auto-fixed by black
7 E123
8 E125
9 E126
10 E127
11 E128
12 E129
13 E501
14 # binary operator on same or next line; mutually exclusive
15 W503
16 W504
3\ No newline at end of file17\ No newline at end of file
diff --git a/setup.py b/setup.py
index 656888e..fbb9cab 100755
--- a/setup.py
+++ b/setup.py
@@ -21,6 +21,7 @@
21import sys21import sys
22from setuptools import setup, find_packages22from setuptools import setup, find_packages
2323
24
24# generic helpers primarily for the long_description25# generic helpers primarily for the long_description
25def generate(*docname_or_string):26def generate(*docname_or_string):
26 marker = '.. pypi description ends here'27 marker = '.. pypi description ends here'
@@ -38,6 +39,7 @@ def generate(*docname_or_string):
38 return '\n'.join(res)39 return '\n'.join(res)
39# end generic helpers40# end generic helpers
4041
42
41install_requires = [43install_requires = [
42 'httplib2',44 'httplib2',
43 'importlib-metadata; python_version < "3.8"',45 'importlib-metadata; python_version < "3.8"',
@@ -53,14 +55,14 @@ setup(
53 name='launchpadlib',55 name='launchpadlib',
54 version='1.10.15.1',56 version='1.10.15.1',
55 packages=find_packages('src'),57 packages=find_packages('src'),
56 package_dir={'':'src'},58 package_dir={'': 'src'},
57 include_package_data=True,59 include_package_data=True,
58 zip_safe=False,60 zip_safe=False,
59 author='The Launchpad developers',61 author='The Launchpad developers',
60 author_email='launchpadlib@lists.launchpad.net',62 author_email='launchpadlib@lists.launchpad.net',
61 maintainer='LAZR Developers',63 maintainer='LAZR Developers',
62 maintainer_email='lazr-developers@lists.launchpad.net',64 maintainer_email='lazr-developers@lists.launchpad.net',
63 download_url= 'https://launchpad.net/launchpadlib/+download',65 download_url='https://launchpad.net/launchpadlib/+download',
64 description=open('README.rst').readline().strip(),66 description=open('README.rst').readline().strip(),
65 long_description=generate(67 long_description=generate(
66 'src/launchpadlib/docs/index.rst',68 'src/launchpadlib/docs/index.rst',
diff --git a/src/launchpadlib/apps.py b/src/launchpadlib/apps.py
index f58dcb4..dc716da 100644
--- a/src/launchpadlib/apps.py
+++ b/src/launchpadlib/apps.py
@@ -48,5 +48,3 @@ class RequestTokenApp(object):
48 self.context, self.web_root,48 self.context, self.web_root,
49 token_format=Credentials.DICT_TOKEN_FORMAT)49 token_format=Credentials.DICT_TOKEN_FORMAT)
50 return json.dumps(token)50 return json.dumps(token)
51
52
diff --git a/src/launchpadlib/bin/launchpad-request-token b/src/launchpadlib/bin/launchpad-request-token
index 2cc7db1..0690b28 100755
--- a/src/launchpadlib/bin/launchpad-request-token
+++ b/src/launchpadlib/bin/launchpad-request-token
@@ -22,6 +22,8 @@ This script will create a Launchpad request token and print to STDOUT
22some JSON data about the token and the available access levels.22some JSON data about the token and the available access levels.
23"""23"""
2424
25from __future__ import print_function
26
25__metaclass__ = type27__metaclass__ = type
2628
27from optparse import OptionParser29from optparse import OptionParser
@@ -45,4 +47,4 @@ if __name__ == '__main__':
45 consumer_name = args[0]47 consumer_name = args[0]
46 app = RequestTokenApp(48 app = RequestTokenApp(
47 options.web_root, consumer_name, options.context)49 options.web_root, consumer_name, options.context)
48 print app.run()50 print(app.run())
diff --git a/src/launchpadlib/credentials.py b/src/launchpadlib/credentials.py
index 5607d20..e2a3350 100644
--- a/src/launchpadlib/credentials.py
+++ b/src/launchpadlib/credentials.py
@@ -63,16 +63,16 @@ from six.moves.urllib.parse import parse_qs
6363
64if bytes is str:64if bytes is str:
65 # Python 265 # Python 2
66 unicode_type = unicode66 unicode_type = unicode # noqa: F821
67else:67else:
68 unicode_type = str68 unicode_type = str
69 69
70from lazr.restfulclient.errors import HTTPError70from lazr.restfulclient.errors import HTTPError
71from lazr.restfulclient.authorize.oauth import (71from lazr.restfulclient.authorize.oauth import (
72 AccessToken as _AccessToken,72 AccessToken as _AccessToken,
73 Consumer,73 Consumer,
74 OAuthAuthorizer,74 OAuthAuthorizer,
75 SystemWideConsumer # Not used directly, just re-imported into here.75 SystemWideConsumer # Not used directly, just re-imported into here.
76 )76 )
7777
78from launchpadlib import uris78from launchpadlib import uris
@@ -271,7 +271,7 @@ class AnonymousAccessToken(_AccessToken):
271 This token can be used for anonymous access.271 This token can be used for anonymous access.
272 """272 """
273 def __init__(self):273 def __init__(self):
274 super(AnonymousAccessToken, self).__init__('','')274 super(AnonymousAccessToken, self).__init__('', '')
275275
276276
277class CredentialStore(object):277class CredentialStore(object):
@@ -436,7 +436,7 @@ class KeyringCredentialStore(CredentialStore):
436 try:436 try:
437 credentials = Credentials.from_string(credential_string)437 credentials = Credentials.from_string(credential_string)
438 return credentials438 return credentials
439 except:439 except Exception:
440 # If any error occurs at this point the most reasonable thing440 # If any error occurs at this point the most reasonable thing
441 # to do is return no credentials, which will require441 # to do is return no credentials, which will require
442 # re-authorization but the user will be able to proceed.442 # re-authorization but the user will be able to proceed.
@@ -733,8 +733,8 @@ class AuthorizeRequestTokenWithBrowser(AuthorizeRequestTokenWithURL):
733 # are discarding the passed-in values for consumer_name and733 # are discarding the passed-in values for consumer_name and
734 # allow_access_levels.734 # allow_access_levels.
735 super(AuthorizeRequestTokenWithBrowser, self).__init__(735 super(AuthorizeRequestTokenWithBrowser, self).__init__(
736 service_root, application_name, None,736 service_root, application_name, None,
737 credential_save_failed)737 credential_save_failed)
738738
739 def notify_end_user_authorization_url(self, authorization_url):739 def notify_end_user_authorization_url(self, authorization_url):
740 """Notify the end-user of the URL."""740 """Notify the end-user of the URL."""
diff --git a/src/launchpadlib/docs/conf.py b/src/launchpadlib/docs/conf.py
index e18d614..2424f52 100644
--- a/src/launchpadlib/docs/conf.py
+++ b/src/launchpadlib/docs/conf.py
@@ -165,6 +165,3 @@ texinfo_documents = [
165 author, 'launchpadlib', 'One line description of project.',165 author, 'launchpadlib', 'One line description of project.',
166 'Miscellaneous'),166 'Miscellaneous'),
167]167]
168
169
170
diff --git a/src/launchpadlib/errors.py b/src/launchpadlib/errors.py
index b9e59a4..87b6500 100644
--- a/src/launchpadlib/errors.py
+++ b/src/launchpadlib/errors.py
@@ -17,4 +17,4 @@
1717
18"""Reimport errors from restfulclient for convenience's sake."""18"""Reimport errors from restfulclient for convenience's sake."""
1919
20from lazr.restfulclient.errors import *20from lazr.restfulclient.errors import * # noqa: F401, F403
diff --git a/src/launchpadlib/launchpad.py b/src/launchpadlib/launchpad.py
index ec88b01..c2c20ed 100644
--- a/src/launchpadlib/launchpad.py
+++ b/src/launchpadlib/launchpad.py
@@ -25,7 +25,7 @@ import errno
25import os25import os
26try:26try:
27 from urllib.parse import urlsplit27 from urllib.parse import urlsplit
28except:28except ImportError:
29 from urlparse import urlsplit29 from urlparse import urlsplit
30import warnings30import warnings
3131
@@ -35,12 +35,12 @@ except ImportError:
35 from httplib2 import ProxyInfo35 from httplib2 import ProxyInfo
36 proxy_info_from_environment = ProxyInfo.from_environment36 proxy_info_from_environment = ProxyInfo.from_environment
3737
38from lazr.restfulclient.resource import (38from lazr.restfulclient.resource import ( # noqa: F401
39 CollectionWithKeyBasedLookup,39 CollectionWithKeyBasedLookup,
40 HostedFile, # Re-import for client convenience40 HostedFile, # Re-import for client convenience
41 ScalarValue, # Re-import for client convenience41 ScalarValue, # Re-import for client convenience
42 ServiceRoot,42 ServiceRoot,
43 )43)
44from lazr.restfulclient.authorize.oauth import SystemWideConsumer44from lazr.restfulclient.authorize.oauth import SystemWideConsumer
45from lazr.restfulclient._browser import RestfulHttp45from lazr.restfulclient._browser import RestfulHttp
46from launchpadlib.credentials import (46from launchpadlib.credentials import (
@@ -58,7 +58,7 @@ from launchpadlib import uris
5858
5959
60# Import old constants for backwards compatibility60# Import old constants for backwards compatibility
61from launchpadlib.uris import STAGING_SERVICE_ROOT, EDGE_SERVICE_ROOT61from launchpadlib.uris import STAGING_SERVICE_ROOT, EDGE_SERVICE_ROOT # noqa: F401
62OAUTH_REALM = 'https://api.launchpad.net'62OAUTH_REALM = 'https://api.launchpad.net'
6363
6464
@@ -598,7 +598,6 @@ class Launchpad(ServiceRoot):
598 argument_name, argument_value, object_value,598 argument_name, argument_value, object_value,
599 object_name, argument_name, object_name))599 object_name, argument_name, object_name))
600600
601
602 @classmethod601 @classmethod
603 def _get_paths(cls, service_root, launchpadlib_dir=None):602 def _get_paths(cls, service_root, launchpadlib_dir=None):
604 """Locate launchpadlib-related user paths and ensure they exist.603 """Locate launchpadlib-related user paths and ensure they exist.
diff --git a/src/launchpadlib/testing/helpers.py b/src/launchpadlib/testing/helpers.py
index 1afddf3..9bec27e 100644
--- a/src/launchpadlib/testing/helpers.py
+++ b/src/launchpadlib/testing/helpers.py
@@ -31,7 +31,7 @@ __all__ = [
31 'nopriv_read_nonprivate',31 'nopriv_read_nonprivate',
32 'salgado_read_nonprivate',32 'salgado_read_nonprivate',
33 'salgado_with_full_permissions',33 'salgado_with_full_permissions',
34 ]34]
3535
36from contextlib import contextmanager36from contextlib import contextmanager
3737
@@ -41,7 +41,7 @@ from launchpadlib.credentials import (
41 AccessToken,41 AccessToken,
42 Credentials,42 Credentials,
43 RequestTokenAuthorizationEngine,43 RequestTokenAuthorizationEngine,
44 )44)
4545
4646
47missing = object()47missing = object()
diff --git a/src/launchpadlib/tests/test_credential_store.py b/src/launchpadlib/tests/test_credential_store.py
index 0aa308b..5ce9e1b 100644
--- a/src/launchpadlib/tests/test_credential_store.py
+++ b/src/launchpadlib/tests/test_credential_store.py
@@ -24,7 +24,7 @@ from base64 import b64decode
2424
25if bytes is str:25if bytes is str:
26 # Python 226 # Python 2
27 unicode_type = unicode27 unicode_type = unicode # noqa: F821
28else:28else:
29 unicode_type = str29 unicode_type = str
3030
diff --git a/src/launchpadlib/tests/test_launchpad.py b/src/launchpadlib/tests/test_launchpad.py
index 9a230d3..e21be2b 100644
--- a/src/launchpadlib/tests/test_launchpad.py
+++ b/src/launchpadlib/tests/test_launchpad.py
@@ -57,6 +57,7 @@ from launchpadlib.credentials import (
57# A dummy service root for use in tests57# A dummy service root for use in tests
58SERVICE_ROOT = "http://api.example.com/"58SERVICE_ROOT = "http://api.example.com/"
5959
60
60class TestResourceTypeClasses(unittest.TestCase):61class TestResourceTypeClasses(unittest.TestCase):
61 """launchpadlib must know about restfulclient's resource types."""62 """launchpadlib must know about restfulclient's resource types."""
6263
@@ -624,6 +625,7 @@ class TestCredenitialSaveFailedCallback(unittest.TestCase):
624 # provided, it is called.625 # provided, it is called.
625626
626 callback_called = []627 callback_called = []
628
627 def callback():629 def callback():
628 # Since we can't rebind "callback_called" here, we'll have to630 # Since we can't rebind "callback_called" here, we'll have to
629 # settle for mutating it to signal success.631 # settle for mutating it to signal success.
diff --git a/src/launchpadlib/uris.py b/src/launchpadlib/uris.py
index 2456a34..ae74669 100644
--- a/src/launchpadlib/uris.py
+++ b/src/launchpadlib/uris.py
@@ -30,7 +30,7 @@ try:
30 from urllib.parse import urlparse30 from urllib.parse import urlparse
31except ImportError:31except ImportError:
32 from urlparse import urlparse32 from urlparse import urlparse
33 33
34import warnings34import warnings
35from lazr.uri import URI35from lazr.uri import URI
3636
@@ -67,7 +67,7 @@ service_roots = dict(
6767
68web_roots = dict(68web_roots = dict(
69 production=LPNET_WEB_ROOT,69 production=LPNET_WEB_ROOT,
70 edge = LPNET_WEB_ROOT,70 edge=LPNET_WEB_ROOT,
71 qastaging=QASTAGING_WEB_ROOT,71 qastaging=QASTAGING_WEB_ROOT,
72 staging=STAGING_WEB_ROOT,72 staging=STAGING_WEB_ROOT,
73 dogfood=DOGFOOD_WEB_ROOT,73 dogfood=DOGFOOD_WEB_ROOT,

Subscribers

People subscribed via source and target branches