Merge ~jugmac00/launchpadlib:flake8-code into launchpadlib:main
- Git
- lp:~jugmac00/launchpadlib
- flake8-code
- Merge into 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) |
Related bugs: |
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
Description of the change
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
1 | diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml | |||
2 | index 015c36c..8ef0d2f 100644 | |||
3 | --- a/.pre-commit-config.yaml | |||
4 | +++ b/.pre-commit-config.yaml | |||
5 | @@ -1,5 +1,7 @@ | |||
6 | 1 | # See https://pre-commit.com for more information | 1 | # See https://pre-commit.com for more information |
7 | 2 | # See https://pre-commit.com/hooks.html for more hooks | 2 | # See https://pre-commit.com/hooks.html for more hooks |
8 | 3 | exclude: ^contrib/ | ||
9 | 4 | |||
10 | 3 | repos: | 5 | repos: |
11 | 4 | - repo: https://github.com/pre-commit/pre-commit-hooks | 6 | - repo: https://github.com/pre-commit/pre-commit-hooks |
12 | 5 | rev: v3.2.0 | 7 | rev: v3.2.0 |
13 | @@ -8,3 +10,8 @@ repos: | |||
14 | 8 | - id: check-merge-conflict | 10 | - id: check-merge-conflict |
15 | 9 | - id: check-xml | 11 | - id: check-xml |
16 | 10 | - id: check-yaml | 12 | - id: check-yaml |
17 | 13 | - id: debug-statements | ||
18 | 14 | - repo: https://github.com/PyCQA/flake8 | ||
19 | 15 | rev: 3.9.2 | ||
20 | 16 | hooks: | ||
21 | 17 | - id: flake8 | ||
22 | diff --git a/setup.cfg b/setup.cfg | |||
23 | index 2a9acf1..121ec76 100644 | |||
24 | --- a/setup.cfg | |||
25 | +++ b/setup.cfg | |||
26 | @@ -1,2 +1,16 @@ | |||
27 | 1 | [bdist_wheel] | 1 | [bdist_wheel] |
28 | 2 | universal = 1 | 2 | universal = 1 |
29 | 3 | |||
30 | 4 | [flake8] | ||
31 | 5 | ignore = | ||
32 | 6 | # indentation / whitespace issues -> will be auto-fixed by black | ||
33 | 7 | E123 | ||
34 | 8 | E125 | ||
35 | 9 | E126 | ||
36 | 10 | E127 | ||
37 | 11 | E128 | ||
38 | 12 | E129 | ||
39 | 13 | E501 | ||
40 | 14 | # binary operator on same or next line; mutually exclusive | ||
41 | 15 | W503 | ||
42 | 16 | W504 | ||
43 | 3 | \ No newline at end of file | 17 | \ No newline at end of file |
44 | diff --git a/setup.py b/setup.py | |||
45 | index 656888e..fbb9cab 100755 | |||
46 | --- a/setup.py | |||
47 | +++ b/setup.py | |||
48 | @@ -21,6 +21,7 @@ | |||
49 | 21 | import sys | 21 | import sys |
50 | 22 | from setuptools import setup, find_packages | 22 | from setuptools import setup, find_packages |
51 | 23 | 23 | ||
52 | 24 | |||
53 | 24 | # generic helpers primarily for the long_description | 25 | # generic helpers primarily for the long_description |
54 | 25 | def generate(*docname_or_string): | 26 | def generate(*docname_or_string): |
55 | 26 | marker = '.. pypi description ends here' | 27 | marker = '.. pypi description ends here' |
56 | @@ -38,6 +39,7 @@ def generate(*docname_or_string): | |||
57 | 38 | return '\n'.join(res) | 39 | return '\n'.join(res) |
58 | 39 | # end generic helpers | 40 | # end generic helpers |
59 | 40 | 41 | ||
60 | 42 | |||
61 | 41 | install_requires = [ | 43 | install_requires = [ |
62 | 42 | 'httplib2', | 44 | 'httplib2', |
63 | 43 | 'importlib-metadata; python_version < "3.8"', | 45 | 'importlib-metadata; python_version < "3.8"', |
64 | @@ -53,14 +55,14 @@ setup( | |||
65 | 53 | name='launchpadlib', | 55 | name='launchpadlib', |
66 | 54 | version='1.10.15.1', | 56 | version='1.10.15.1', |
67 | 55 | packages=find_packages('src'), | 57 | packages=find_packages('src'), |
69 | 56 | package_dir={'':'src'}, | 58 | package_dir={'': 'src'}, |
70 | 57 | include_package_data=True, | 59 | include_package_data=True, |
71 | 58 | zip_safe=False, | 60 | zip_safe=False, |
72 | 59 | author='The Launchpad developers', | 61 | author='The Launchpad developers', |
73 | 60 | author_email='launchpadlib@lists.launchpad.net', | 62 | author_email='launchpadlib@lists.launchpad.net', |
74 | 61 | maintainer='LAZR Developers', | 63 | maintainer='LAZR Developers', |
75 | 62 | maintainer_email='lazr-developers@lists.launchpad.net', | 64 | maintainer_email='lazr-developers@lists.launchpad.net', |
77 | 63 | download_url= 'https://launchpad.net/launchpadlib/+download', | 65 | download_url='https://launchpad.net/launchpadlib/+download', |
78 | 64 | description=open('README.rst').readline().strip(), | 66 | description=open('README.rst').readline().strip(), |
79 | 65 | long_description=generate( | 67 | long_description=generate( |
80 | 66 | 'src/launchpadlib/docs/index.rst', | 68 | 'src/launchpadlib/docs/index.rst', |
81 | diff --git a/src/launchpadlib/apps.py b/src/launchpadlib/apps.py | |||
82 | index f58dcb4..dc716da 100644 | |||
83 | --- a/src/launchpadlib/apps.py | |||
84 | +++ b/src/launchpadlib/apps.py | |||
85 | @@ -48,5 +48,3 @@ class RequestTokenApp(object): | |||
86 | 48 | self.context, self.web_root, | 48 | self.context, self.web_root, |
87 | 49 | token_format=Credentials.DICT_TOKEN_FORMAT) | 49 | token_format=Credentials.DICT_TOKEN_FORMAT) |
88 | 50 | return json.dumps(token) | 50 | return json.dumps(token) |
89 | 51 | |||
90 | 52 | |||
91 | diff --git a/src/launchpadlib/bin/launchpad-request-token b/src/launchpadlib/bin/launchpad-request-token | |||
92 | index 2cc7db1..0690b28 100755 | |||
93 | --- a/src/launchpadlib/bin/launchpad-request-token | |||
94 | +++ b/src/launchpadlib/bin/launchpad-request-token | |||
95 | @@ -22,6 +22,8 @@ This script will create a Launchpad request token and print to STDOUT | |||
96 | 22 | some JSON data about the token and the available access levels. | 22 | some JSON data about the token and the available access levels. |
97 | 23 | """ | 23 | """ |
98 | 24 | 24 | ||
99 | 25 | from __future__ import print_function | ||
100 | 26 | |||
101 | 25 | __metaclass__ = type | 27 | __metaclass__ = type |
102 | 26 | 28 | ||
103 | 27 | from optparse import OptionParser | 29 | from optparse import OptionParser |
104 | @@ -45,4 +47,4 @@ if __name__ == '__main__': | |||
105 | 45 | consumer_name = args[0] | 47 | consumer_name = args[0] |
106 | 46 | app = RequestTokenApp( | 48 | app = RequestTokenApp( |
107 | 47 | options.web_root, consumer_name, options.context) | 49 | options.web_root, consumer_name, options.context) |
109 | 48 | print app.run() | 50 | print(app.run()) |
110 | diff --git a/src/launchpadlib/credentials.py b/src/launchpadlib/credentials.py | |||
111 | index 5607d20..e2a3350 100644 | |||
112 | --- a/src/launchpadlib/credentials.py | |||
113 | +++ b/src/launchpadlib/credentials.py | |||
114 | @@ -63,16 +63,16 @@ from six.moves.urllib.parse import parse_qs | |||
115 | 63 | 63 | ||
116 | 64 | if bytes is str: | 64 | if bytes is str: |
117 | 65 | # Python 2 | 65 | # Python 2 |
119 | 66 | unicode_type = unicode | 66 | unicode_type = unicode # noqa: F821 |
120 | 67 | else: | 67 | else: |
121 | 68 | unicode_type = str | 68 | unicode_type = str |
123 | 69 | 69 | ||
124 | 70 | from lazr.restfulclient.errors import HTTPError | 70 | from lazr.restfulclient.errors import HTTPError |
125 | 71 | from lazr.restfulclient.authorize.oauth import ( | 71 | from lazr.restfulclient.authorize.oauth import ( |
126 | 72 | AccessToken as _AccessToken, | 72 | AccessToken as _AccessToken, |
127 | 73 | Consumer, | 73 | Consumer, |
128 | 74 | OAuthAuthorizer, | 74 | OAuthAuthorizer, |
130 | 75 | SystemWideConsumer # Not used directly, just re-imported into here. | 75 | SystemWideConsumer # Not used directly, just re-imported into here. |
131 | 76 | ) | 76 | ) |
132 | 77 | 77 | ||
133 | 78 | from launchpadlib import uris | 78 | from launchpadlib import uris |
134 | @@ -271,7 +271,7 @@ class AnonymousAccessToken(_AccessToken): | |||
135 | 271 | This token can be used for anonymous access. | 271 | This token can be used for anonymous access. |
136 | 272 | """ | 272 | """ |
137 | 273 | def __init__(self): | 273 | def __init__(self): |
139 | 274 | super(AnonymousAccessToken, self).__init__('','') | 274 | super(AnonymousAccessToken, self).__init__('', '') |
140 | 275 | 275 | ||
141 | 276 | 276 | ||
142 | 277 | class CredentialStore(object): | 277 | class CredentialStore(object): |
143 | @@ -436,7 +436,7 @@ class KeyringCredentialStore(CredentialStore): | |||
144 | 436 | try: | 436 | try: |
145 | 437 | credentials = Credentials.from_string(credential_string) | 437 | credentials = Credentials.from_string(credential_string) |
146 | 438 | return credentials | 438 | return credentials |
148 | 439 | except: | 439 | except Exception: |
149 | 440 | # If any error occurs at this point the most reasonable thing | 440 | # If any error occurs at this point the most reasonable thing |
150 | 441 | # to do is return no credentials, which will require | 441 | # to do is return no credentials, which will require |
151 | 442 | # re-authorization but the user will be able to proceed. | 442 | # re-authorization but the user will be able to proceed. |
152 | @@ -733,8 +733,8 @@ class AuthorizeRequestTokenWithBrowser(AuthorizeRequestTokenWithURL): | |||
153 | 733 | # are discarding the passed-in values for consumer_name and | 733 | # are discarding the passed-in values for consumer_name and |
154 | 734 | # allow_access_levels. | 734 | # allow_access_levels. |
155 | 735 | super(AuthorizeRequestTokenWithBrowser, self).__init__( | 735 | super(AuthorizeRequestTokenWithBrowser, self).__init__( |
158 | 736 | service_root, application_name, None, | 736 | service_root, application_name, None, |
159 | 737 | credential_save_failed) | 737 | credential_save_failed) |
160 | 738 | 738 | ||
161 | 739 | def notify_end_user_authorization_url(self, authorization_url): | 739 | def notify_end_user_authorization_url(self, authorization_url): |
162 | 740 | """Notify the end-user of the URL.""" | 740 | """Notify the end-user of the URL.""" |
163 | diff --git a/src/launchpadlib/docs/conf.py b/src/launchpadlib/docs/conf.py | |||
164 | index e18d614..2424f52 100644 | |||
165 | --- a/src/launchpadlib/docs/conf.py | |||
166 | +++ b/src/launchpadlib/docs/conf.py | |||
167 | @@ -165,6 +165,3 @@ texinfo_documents = [ | |||
168 | 165 | author, 'launchpadlib', 'One line description of project.', | 165 | author, 'launchpadlib', 'One line description of project.', |
169 | 166 | 'Miscellaneous'), | 166 | 'Miscellaneous'), |
170 | 167 | ] | 167 | ] |
171 | 168 | |||
172 | 169 | |||
173 | 170 | |||
174 | diff --git a/src/launchpadlib/errors.py b/src/launchpadlib/errors.py | |||
175 | index b9e59a4..87b6500 100644 | |||
176 | --- a/src/launchpadlib/errors.py | |||
177 | +++ b/src/launchpadlib/errors.py | |||
178 | @@ -17,4 +17,4 @@ | |||
179 | 17 | 17 | ||
180 | 18 | """Reimport errors from restfulclient for convenience's sake.""" | 18 | """Reimport errors from restfulclient for convenience's sake.""" |
181 | 19 | 19 | ||
183 | 20 | from lazr.restfulclient.errors import * | 20 | from lazr.restfulclient.errors import * # noqa: F401, F403 |
184 | diff --git a/src/launchpadlib/launchpad.py b/src/launchpadlib/launchpad.py | |||
185 | index ec88b01..c2c20ed 100644 | |||
186 | --- a/src/launchpadlib/launchpad.py | |||
187 | +++ b/src/launchpadlib/launchpad.py | |||
188 | @@ -25,7 +25,7 @@ import errno | |||
189 | 25 | import os | 25 | import os |
190 | 26 | try: | 26 | try: |
191 | 27 | from urllib.parse import urlsplit | 27 | from urllib.parse import urlsplit |
193 | 28 | except: | 28 | except ImportError: |
194 | 29 | from urlparse import urlsplit | 29 | from urlparse import urlsplit |
195 | 30 | import warnings | 30 | import warnings |
196 | 31 | 31 | ||
197 | @@ -35,12 +35,12 @@ except ImportError: | |||
198 | 35 | from httplib2 import ProxyInfo | 35 | from httplib2 import ProxyInfo |
199 | 36 | proxy_info_from_environment = ProxyInfo.from_environment | 36 | proxy_info_from_environment = ProxyInfo.from_environment |
200 | 37 | 37 | ||
202 | 38 | from lazr.restfulclient.resource import ( | 38 | from lazr.restfulclient.resource import ( # noqa: F401 |
203 | 39 | CollectionWithKeyBasedLookup, | 39 | CollectionWithKeyBasedLookup, |
204 | 40 | HostedFile, # Re-import for client convenience | 40 | HostedFile, # Re-import for client convenience |
205 | 41 | ScalarValue, # Re-import for client convenience | 41 | ScalarValue, # Re-import for client convenience |
206 | 42 | ServiceRoot, | 42 | ServiceRoot, |
208 | 43 | ) | 43 | ) |
209 | 44 | from lazr.restfulclient.authorize.oauth import SystemWideConsumer | 44 | from lazr.restfulclient.authorize.oauth import SystemWideConsumer |
210 | 45 | from lazr.restfulclient._browser import RestfulHttp | 45 | from lazr.restfulclient._browser import RestfulHttp |
211 | 46 | from launchpadlib.credentials import ( | 46 | from launchpadlib.credentials import ( |
212 | @@ -58,7 +58,7 @@ from launchpadlib import uris | |||
213 | 58 | 58 | ||
214 | 59 | 59 | ||
215 | 60 | # Import old constants for backwards compatibility | 60 | # Import old constants for backwards compatibility |
217 | 61 | from launchpadlib.uris import STAGING_SERVICE_ROOT, EDGE_SERVICE_ROOT | 61 | from launchpadlib.uris import STAGING_SERVICE_ROOT, EDGE_SERVICE_ROOT # noqa: F401 |
218 | 62 | OAUTH_REALM = 'https://api.launchpad.net' | 62 | OAUTH_REALM = 'https://api.launchpad.net' |
219 | 63 | 63 | ||
220 | 64 | 64 | ||
221 | @@ -598,7 +598,6 @@ class Launchpad(ServiceRoot): | |||
222 | 598 | argument_name, argument_value, object_value, | 598 | argument_name, argument_value, object_value, |
223 | 599 | object_name, argument_name, object_name)) | 599 | object_name, argument_name, object_name)) |
224 | 600 | 600 | ||
225 | 601 | |||
226 | 602 | @classmethod | 601 | @classmethod |
227 | 603 | def _get_paths(cls, service_root, launchpadlib_dir=None): | 602 | def _get_paths(cls, service_root, launchpadlib_dir=None): |
228 | 604 | """Locate launchpadlib-related user paths and ensure they exist. | 603 | """Locate launchpadlib-related user paths and ensure they exist. |
229 | diff --git a/src/launchpadlib/testing/helpers.py b/src/launchpadlib/testing/helpers.py | |||
230 | index 1afddf3..9bec27e 100644 | |||
231 | --- a/src/launchpadlib/testing/helpers.py | |||
232 | +++ b/src/launchpadlib/testing/helpers.py | |||
233 | @@ -31,7 +31,7 @@ __all__ = [ | |||
234 | 31 | 'nopriv_read_nonprivate', | 31 | 'nopriv_read_nonprivate', |
235 | 32 | 'salgado_read_nonprivate', | 32 | 'salgado_read_nonprivate', |
236 | 33 | 'salgado_with_full_permissions', | 33 | 'salgado_with_full_permissions', |
238 | 34 | ] | 34 | ] |
239 | 35 | 35 | ||
240 | 36 | from contextlib import contextmanager | 36 | from contextlib import contextmanager |
241 | 37 | 37 | ||
242 | @@ -41,7 +41,7 @@ from launchpadlib.credentials import ( | |||
243 | 41 | AccessToken, | 41 | AccessToken, |
244 | 42 | Credentials, | 42 | Credentials, |
245 | 43 | RequestTokenAuthorizationEngine, | 43 | RequestTokenAuthorizationEngine, |
247 | 44 | ) | 44 | ) |
248 | 45 | 45 | ||
249 | 46 | 46 | ||
250 | 47 | missing = object() | 47 | missing = object() |
251 | diff --git a/src/launchpadlib/tests/test_credential_store.py b/src/launchpadlib/tests/test_credential_store.py | |||
252 | index 0aa308b..5ce9e1b 100644 | |||
253 | --- a/src/launchpadlib/tests/test_credential_store.py | |||
254 | +++ b/src/launchpadlib/tests/test_credential_store.py | |||
255 | @@ -24,7 +24,7 @@ from base64 import b64decode | |||
256 | 24 | 24 | ||
257 | 25 | if bytes is str: | 25 | if bytes is str: |
258 | 26 | # Python 2 | 26 | # Python 2 |
260 | 27 | unicode_type = unicode | 27 | unicode_type = unicode # noqa: F821 |
261 | 28 | else: | 28 | else: |
262 | 29 | unicode_type = str | 29 | unicode_type = str |
263 | 30 | 30 | ||
264 | diff --git a/src/launchpadlib/tests/test_launchpad.py b/src/launchpadlib/tests/test_launchpad.py | |||
265 | index 9a230d3..e21be2b 100644 | |||
266 | --- a/src/launchpadlib/tests/test_launchpad.py | |||
267 | +++ b/src/launchpadlib/tests/test_launchpad.py | |||
268 | @@ -57,6 +57,7 @@ from launchpadlib.credentials import ( | |||
269 | 57 | # A dummy service root for use in tests | 57 | # A dummy service root for use in tests |
270 | 58 | SERVICE_ROOT = "http://api.example.com/" | 58 | SERVICE_ROOT = "http://api.example.com/" |
271 | 59 | 59 | ||
272 | 60 | |||
273 | 60 | class TestResourceTypeClasses(unittest.TestCase): | 61 | class TestResourceTypeClasses(unittest.TestCase): |
274 | 61 | """launchpadlib must know about restfulclient's resource types.""" | 62 | """launchpadlib must know about restfulclient's resource types.""" |
275 | 62 | 63 | ||
276 | @@ -624,6 +625,7 @@ class TestCredenitialSaveFailedCallback(unittest.TestCase): | |||
277 | 624 | # provided, it is called. | 625 | # provided, it is called. |
278 | 625 | 626 | ||
279 | 626 | callback_called = [] | 627 | callback_called = [] |
280 | 628 | |||
281 | 627 | def callback(): | 629 | def callback(): |
282 | 628 | # Since we can't rebind "callback_called" here, we'll have to | 630 | # Since we can't rebind "callback_called" here, we'll have to |
283 | 629 | # settle for mutating it to signal success. | 631 | # settle for mutating it to signal success. |
284 | diff --git a/src/launchpadlib/uris.py b/src/launchpadlib/uris.py | |||
285 | index 2456a34..ae74669 100644 | |||
286 | --- a/src/launchpadlib/uris.py | |||
287 | +++ b/src/launchpadlib/uris.py | |||
288 | @@ -30,7 +30,7 @@ try: | |||
289 | 30 | from urllib.parse import urlparse | 30 | from urllib.parse import urlparse |
290 | 31 | except ImportError: | 31 | except ImportError: |
291 | 32 | from urlparse import urlparse | 32 | from urlparse import urlparse |
293 | 33 | 33 | ||
294 | 34 | import warnings | 34 | import warnings |
295 | 35 | from lazr.uri import URI | 35 | from lazr.uri import URI |
296 | 36 | 36 | ||
297 | @@ -67,7 +67,7 @@ service_roots = dict( | |||
298 | 67 | 67 | ||
299 | 68 | web_roots = dict( | 68 | web_roots = dict( |
300 | 69 | production=LPNET_WEB_ROOT, | 69 | production=LPNET_WEB_ROOT, |
302 | 70 | edge = LPNET_WEB_ROOT, | 70 | edge=LPNET_WEB_ROOT, |
303 | 71 | qastaging=QASTAGING_WEB_ROOT, | 71 | qastaging=QASTAGING_WEB_ROOT, |
304 | 72 | staging=STAGING_WEB_ROOT, | 72 | staging=STAGING_WEB_ROOT, |
305 | 73 | dogfood=DOGFOOD_WEB_ROOT, | 73 | dogfood=DOGFOOD_WEB_ROOT, |