Skip to content

Commit 5bcc431

Browse files
authored
lint: update pre-commit and run on all files (#161)
* lint: remove language_version from pre-commit config * lint: run pre-commit autoupdate and use default flake8 * lint: add line length of 120 to setup.cfg * lint: fix isort config for black * lint: run pre-commit run --all-files * fix: add missing module copyright and docstring * lint: replace flake8 env with a linters env running pre-commit in tox.ini
1 parent ee240fa commit 5bcc431

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+143
-120
lines changed

.editorconfig

-1
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,3 @@ tab_width=4
2727
[{*.yaml,*.yml}]
2828
indent_style=space
2929
indent_size=2
30-

.pre-commit-config.yaml

+8-11
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ fail_fast: false
33
repos:
44

55
- repo: https://github.com/pre-commit/pre-commit-hooks.git
6-
rev: v2.1.0
6+
rev: v3.4.0
77
hooks:
88
- id: trailing-whitespace
99
- id: end-of-file-fixer
@@ -15,28 +15,25 @@ repos:
1515
- id: check-added-large-files
1616
args: ['--maxkb=1600']
1717
- id: debug-statements
18-
- id: flake8
19-
args: [--max-line-length=120]
20-
language_version: python3.7
2118
- id: check-merge-conflict
2219

20+
- repo: 'https://gitlab.com/pycqa/flake8'
21+
rev: 3.9.0
22+
hooks:
23+
- id: flake8
24+
2325
- repo: 'https://github.com/ambv/black'
24-
# stable
25-
rev: 19.10b0
26+
rev: 20.8b1
2627
hooks:
2728
- id: black
2829
args: ['--safe']
29-
language_version: python3.7
3030

3131
- repo: 'https://github.com/chewse/pre-commit-mirrors-pydocstyle'
32-
# 2.1.1
3332
rev: v2.1.1
3433
hooks:
3534
- id: pydocstyle
36-
language_version: python3.7
3735

3836
- repo: https://github.com/pre-commit/mirrors-isort
39-
# v4.3.15
40-
rev: v4.3.15
37+
rev: v5.7.0
4138
hooks:
4239
- id: isort

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -173,4 +173,4 @@
173173
incurred by, or claims asserted against, such Contributor by reason
174174
of your accepting any such warranty or additional liability.
175175

176-
END OF TERMS AND CONDITIONS
176+
END OF TERMS AND CONDITIONS

docs/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ help:
1717
# Catch-all target: route all unknown targets to Sphinx using the new
1818
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
1919
%: Makefile
20-
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/changelog.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
.. _changelog:
22

3-
.. include:: ../CHANGES.rst
3+
.. include:: ../CHANGES.rst

docs/tutorials/eodag_workspace/eodag_conf.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ AmazonWS:
2222
aws_secret_access_key:
2323
airbus-ds:
2424
credentials:
25-
apikey:
25+
apikey:

docs/tutorials/tuto_bandmath.nblink

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
22
"path": "../../examples/tuto_bandmath.ipynb"
3-
}
3+
}

docs/tutorials/tuto_basics.nblink

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
22
"path": "../../examples/tuto_basics.ipynb"
3-
}
3+
}
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
22
"path": "../../examples/tuto_burnt_areas_gpt.ipynb"
3-
}
3+
}
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
22
"path": "../../examples/tuto_burnt_areas_snappy.ipynb"
3-
}
3+
}
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
22
"path": "../../examples/tuto_ship_detection.ipynb"
3-
}
3+
}

eodag/api/core.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -968,8 +968,10 @@ def load_stac_items(
968968
)
969969
# save plugin._request and mock it to make return loaded static results
970970
plugin_request = plugin._request
971-
plugin._request = lambda url, info_message=None, exception_message=None: MockResponse(
972-
feature_collection, 200
971+
plugin._request = (
972+
lambda url, info_message=None, exception_message=None: MockResponse(
973+
feature_collection, 200
974+
)
973975
)
974976

975977
# save preferred_provider and use provided one instead

eodag/api/product/metadata_mapping.py

+7-10
Original file line numberDiff line numberDiff line change
@@ -344,16 +344,13 @@ def convert_s2msil2a_title_to_aws_productinfo(string):
344344
id_match = id_regex.match(string)
345345
if id_match:
346346
id_dict = id_match.groupdict()
347-
return (
348-
"https://roda.sentinel-hub.com/sentinel-s2-l2a/tiles/%s/%s/%s/%s/%s/%s/0/{collection}.json"
349-
% (
350-
id_dict["tile1"],
351-
id_dict["tile2"],
352-
id_dict["tile3"],
353-
id_dict["year"],
354-
int(id_dict["month"]),
355-
int(id_dict["day"]),
356-
)
347+
return "https://roda.sentinel-hub.com/sentinel-s2-l2a/tiles/%s/%s/%s/%s/%s/%s/0/{collection}.json" % (
348+
id_dict["tile1"],
349+
id_dict["tile2"],
350+
id_dict["tile3"],
351+
id_dict["year"],
352+
int(id_dict["month"]),
353+
int(id_dict["day"]),
357354
)
358355
else:
359356
logger.error("Could not extract title infos from %s" % string)

eodag/api/search_result.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ def from_geojson(feature_collection):
5757
)
5858

5959
def as_geojson_object(self):
60-
"""GeoJSON representation of SearchResult
61-
"""
60+
"""GeoJSON representation of SearchResult"""
6261
return {
6362
"type": "FeatureCollection",
6463
"features": [product.as_dict() for product in self],

eodag/plugins/download/aws.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,7 @@
139139

140140

141141
class AwsDownload(Download):
142-
"""Download on AWS using S3 protocol
143-
"""
142+
"""Download on AWS using S3 protocol"""
144143

145144
def download(self, product, auth=None, progress_callback=None, **kwargs):
146145
"""Download method for AWS S3 API.
@@ -303,7 +302,9 @@ def download(self, product, auth=None, progress_callback=None, **kwargs):
303302
try:
304303
s3_objects = authenticated_objects[bucket_name]
305304

306-
for product_chunk in s3_objects.filter(Prefix=prefix,):
305+
for product_chunk in s3_objects.filter(
306+
Prefix=prefix,
307+
):
307308
chunck_rel_path = self.get_chunck_dest_path(
308309
product,
309310
product_chunk,
@@ -500,8 +501,7 @@ def get_bucket_name_and_prefix(self, product, url=None):
500501
return bucket, prefix
501502

502503
def finalize_s2_safe_product(self, product_path):
503-
"""Add missing dirs to downloaded product
504-
"""
504+
"""Add missing dirs to downloaded product"""
505505
try:
506506
logger.debug("Finalize SAFE product")
507507
manifest_path = [
@@ -541,8 +541,7 @@ def finalize_s2_safe_product(self, product_path):
541541
raise DownloadError(e)
542542

543543
def get_chunck_dest_path(self, product, chunk, dir_prefix, build_safe=False):
544-
"""Get chunck destination path
545-
"""
544+
"""Get chunck destination path"""
546545
if build_safe:
547546
# S2 common
548547
if "S2_MSI" in product.product_type:

eodag/plugins/download/base.py

+7-13
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def download(
5959
progress_callback=None,
6060
wait=DEFAULT_DOWNLOAD_WAIT,
6161
timeout=DEFAULT_DOWNLOAD_TIMEOUT,
62-
**kwargs
62+
**kwargs,
6363
):
6464
"""
6565
Base download method. Not available, should be defined for each plugin
@@ -207,7 +207,8 @@ def _finalize(self, fs_path, **kwargs):
207207
bar.position = 2
208208
for fileinfo in fileinfos:
209209
zfile.extract(
210-
fileinfo, path=os.path.join(outputs_prefix, product_path),
210+
fileinfo,
211+
path=os.path.join(outputs_prefix, product_path),
211212
)
212213
bar(1)
213214
# Handle depth levels in the product archive. For example, if the downloaded archive was
@@ -228,7 +229,7 @@ def download_all(
228229
progress_callback=None,
229230
wait=DEFAULT_DOWNLOAD_WAIT,
230231
timeout=DEFAULT_DOWNLOAD_TIMEOUT,
231-
**kwargs
232+
**kwargs,
232233
):
233234
"""
234235
A sequential download_all implementation
@@ -282,7 +283,7 @@ def download_all(
282283
progress_callback=progress_callback,
283284
wait=wait,
284285
timeout=-1,
285-
**kwargs
286+
**kwargs,
286287
)
287288
)
288289

@@ -333,15 +334,8 @@ def download_all(
333334
wait_seconds = (products[0].next_try - datetime.now()).seconds
334335
retry_count += 1
335336
info_message = (
336-
"[Retry #%s, %s/%s D/L] Waiting %ss until next download try (retry every %s' for %s')"
337-
% (
338-
retry_count,
339-
(nb_products - len(products)),
340-
nb_products,
341-
wait_seconds,
342-
wait,
343-
timeout,
344-
)
337+
f"[Retry #{retry_count}, {nb_products - len(products)}/{nb_products} D/L] "
338+
f"Waiting {wait_seconds}s until next download try (retry every {wait}' for {timeout}')"
345339
)
346340
logger.info(info_message)
347341
nb_info.display_html(info_message)

eodag/plugins/download/http.py

+9-4
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,10 @@ def download(
136136
self.config, "dl_url_params", {}
137137
)
138138
with requests.get(
139-
url, stream=True, auth=auth, params=params,
139+
url,
140+
stream=True,
141+
auth=auth,
142+
params=params,
140143
) as stream:
141144
try:
142145
stream.raise_for_status()
@@ -265,8 +268,7 @@ def _download_assets(
265268
progress_callback=None,
266269
**kwargs
267270
):
268-
"""Download product assets if they exist
269-
"""
271+
"""Download product assets if they exist"""
270272
assets_urls = [
271273
a["href"] for a in getattr(product, "assets", {}).values() if "href" in a
272274
]
@@ -307,7 +309,10 @@ def _download_assets(
307309
self.config, "dl_url_params", {}
308310
)
309311
with requests.get(
310-
asset_url, stream=True, auth=auth, params=params,
312+
asset_url,
313+
stream=True,
314+
auth=auth,
315+
params=params,
311316
) as stream:
312317
try:
313318
stream.raise_for_status()

eodag/plugins/manager.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,10 @@ def __init__(self, providers_config):
8080
self.product_type_to_provider_config_map = {}
8181
for provider_config in providers_config.values():
8282
for product_type in provider_config.products:
83-
product_type_providers = self.product_type_to_provider_config_map.setdefault( # noqa
84-
product_type, []
83+
product_type_providers = (
84+
self.product_type_to_provider_config_map.setdefault( # noqa
85+
product_type, []
86+
)
8587
)
8688
product_type_providers.append(provider_config)
8789
product_type_providers.sort(key=attrgetter("priority"), reverse=True)

eodag/plugins/search/static_stac_search.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,10 @@ def query(self, items_per_page=None, page=None, count=True, **kwargs):
7474

7575
# save StaticStacSearch._request and mock it to make return loaded static results
7676
stacapi_request = self._request
77-
self._request = lambda url, info_message=None, exception_message=None: MockResponse(
78-
feature_collection, 200
77+
self._request = (
78+
lambda url, info_message=None, exception_message=None: MockResponse(
79+
feature_collection, 200
80+
)
7981
)
8082

8183
# query on mocked StacSearch

eodag/rest/__init__.py

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# -*- coding: utf-8 -*-
2+
# Copyright 2021, CS GROUP - France, http://www.c-s.fr
3+
#
4+
# This file is part of EODAG project
5+
# https://www.github.com/CS-SI/EODAG
6+
#
7+
# Licensed under the Apache License, Version 2.0 (the "License");
8+
# you may not use this file except in compliance with the License.
9+
# You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
"""EODAG REST API"""

eodag/rest/server.py

+9-10
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,9 @@
3030
from flask import abort, jsonify, make_response, request, send_file
3131

3232
from eodag.config import load_stac_api_config
33-
from eodag.utils.exceptions import (
34-
MisconfiguredError,
35-
NoMatchingProductType,
36-
NotAvailableError,
37-
UnsupportedProductType,
38-
UnsupportedProvider,
39-
ValidationError,
40-
)
41-
4233
from eodag.rest.utils import ( # get_stac_landing_page,; get_stac_product_types_catalog,; search_products,
4334
download_stac_item_by_id,
35+
get_detailled_collections_list,
4436
get_stac_catalogs,
4537
get_stac_collection_by_id,
4638
get_stac_collections,
@@ -49,7 +41,14 @@
4941
get_stac_item_by_id,
5042
load_stac_config,
5143
search_stac_items,
52-
get_detailled_collections_list,
44+
)
45+
from eodag.utils.exceptions import (
46+
MisconfiguredError,
47+
NoMatchingProductType,
48+
NotAvailableError,
49+
UnsupportedProductType,
50+
UnsupportedProvider,
51+
ValidationError,
5352
)
5453

5554
logger = logging.getLogger("eodag.rest.server")

eodag/rest/server.wsgi

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env python
22

3-
from eodag.rest.server import app as application
3+
from eodag.rest.server import app as application # noqa
44
from eodag.utils.logging import setup_logging
5+
56
setup_logging(verbose=3)

eodag/rest/stac.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,9 @@ def get_stac_items(self, search_results, catalog):
292292
# provide static catalog to build features
293293
if "search?" in catalog["url"]:
294294
catalog["url"] = os.path.join(
295-
catalog["url"].split("search?")[0], "collections", catalog["id"],
295+
catalog["url"].split("search?")[0],
296+
"collections",
297+
catalog["id"],
296298
)
297299
else:
298300
catalog["url"] = catalog["url"].split("?")[0]
@@ -674,7 +676,7 @@ def __update_data_from_catalog_config(self, catalog_config):
674676
return True
675677

676678
def set_children(self, children=[]):
677-
""" set catalog children / links
679+
"""set catalog children / links
678680
679681
:param children: children list
680682
:type children: list

0 commit comments

Comments
 (0)