From 8020109fa03dc987cf7a7a22cdea0ef24782a899 Mon Sep 17 00:00:00 2001 From: SRM Date: Tue, 25 Jan 2022 09:59:54 +0000 Subject: [PATCH 01/13] Add linting with flake8, black & isort - Remove python-env from tox.ini files, use gh-actions matrix for running different python versions - Define tox runs as `tox -e [lint/format/flake8/test]` --- .github/workflows/tests.yml | 6 +++ tox.ini | 82 +++++++++++++++++++++++-------------- 2 files changed, 57 insertions(+), 31 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 41c0a701..af06e2d3 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -43,5 +43,11 @@ jobs: run: | python -m pip install --upgrade pip python -m pip install tox tox-gh-actions + - name: Lint with tox + run: tox -e lint + # - name: Format with tox + # run: tox -e format + - name: Flake8 with tox + run: tox -e flake8 - name: Test with tox run: tox diff --git a/tox.ini b/tox.ini index 7e790d22..76721d38 100644 --- a/tox.ini +++ b/tox.ini @@ -1,44 +1,42 @@ [tox] -envlist = py37,py38,py39,py310 +envlist = + lint, + format, + flake8, + test -[gh-actions] -python = - 3.7: py37 - 3.8: py38 - 3.9: py39 - 3.10: py310 - -[testenv] +[testenv:test] extras = test -commands= +commands = python -m pytest --cov --cov-report xml --cov-report term-missing --ignore=venv -# Lint -[flake8] -exclude = .git,__pycache__,docs/source/conf.py,old,build,dist -max-line-length = 90 - -[mypy] -no_strict_optional = True -ignore_missing_imports = True - -[tool:isort] -include_trailing_comma = True -multi_line_output = 3 -line_length = 90 -known_first_party = solaris -default_section = THIRDPARTY - -# Autoformatter -[testenv:black] -basepython = python3 +[testenv:lint] +basepython = python3.9 skip_install = true -deps = +deps = + isort black commands = + - isort --check-only --df . + - black --check --diff --color . + +[testenv:flake8] +basepython = python3.9 +skip_install = true +deps = flake8 +commands = + - flake8 + +[testenv:format] +basepython = python3.9 +skip_install = true +deps = + isort black +commands = + - isort . + - black . -# Release tooling [testenv:build] basepython = python3 skip_install = true @@ -60,3 +58,25 @@ deps = commands = {[testenv:build]commands} twine upload --skip-existing dist/* + +[flake8] +extend-ignore = + E203, +exclude = + .git, + __pycache__, + docs/source/conf.py, + old, + build, + dist, + .tox +max-line-length = 88 +max-complexity = 10 + +[isort] +profile = black + +[black] +line-length = 88 +target-version = ['py37', 'py38', 'py39', 'py310'] +experimental_string_processing = true \ No newline at end of file From 94ba0a9795bdae4c4055b15fae1c072dc25537a1 Mon Sep 17 00:00:00 2001 From: SRM Date: Tue, 25 Jan 2022 10:08:22 +0000 Subject: [PATCH 02/13] Change basepython to python3 from python3.9. Add test run with tox. --- .github/workflows/tests.yml | 2 +- tox.ini | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index af06e2d3..13425e56 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -50,4 +50,4 @@ jobs: - name: Flake8 with tox run: tox -e flake8 - name: Test with tox - run: tox + run: tox -e test diff --git a/tox.ini b/tox.ini index 76721d38..7e291f56 100644 --- a/tox.ini +++ b/tox.ini @@ -11,7 +11,7 @@ commands = python -m pytest --cov --cov-report xml --cov-report term-missing --ignore=venv [testenv:lint] -basepython = python3.9 +basepython = python3 skip_install = true deps = isort @@ -21,14 +21,14 @@ commands = - black --check --diff --color . [testenv:flake8] -basepython = python3.9 +basepython = python3 skip_install = true deps = flake8 commands = - flake8 [testenv:format] -basepython = python3.9 +basepython = python3 skip_install = true deps = isort From 84bd51f374c859a79503001412cc2d0bf4e32e44 Mon Sep 17 00:00:00 2001 From: SRM Date: Tue, 25 Jan 2022 10:19:44 +0000 Subject: [PATCH 03/13] Add python3.10 to the github runner matrix --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 13425e56..02c34c09 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -11,7 +11,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.8", "3.9"] + python-version: ["3.8", "3.9", "3.10"] gdal-version: ["3.4.0", "3.3.3"] include: - python-version: "3.8" From 8075792839f4c8ec4661026d9dc3fbc68ae5b414 Mon Sep 17 00:00:00 2001 From: SRM Date: Fri, 28 Jan 2022 18:56:13 +0530 Subject: [PATCH 04/13] Use ubuntu-small osgeo container - Tested github-actions locally using act. - osgeo ubuntu-large images are 1.4 GB in size, takes some time to run this locally - Replacing this with ubuntu-small runs it faster with no side effects --- .github/workflows/tests.yml | 4 ++-- tox.ini | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 02c34c09..3cf063fb 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -7,7 +7,7 @@ jobs: build: runs-on: ubuntu-latest name: Docker | GDAL=${{ matrix.gdal-version }} | python=${{ matrix.python-version }} - container: osgeo/gdal:ubuntu-full-${{ matrix.gdal-version }} + container: osgeo/gdal:ubuntu-small-${{ matrix.gdal-version }} strategy: fail-fast: false matrix: @@ -42,7 +42,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install tox tox-gh-actions + python -m pip install tox - name: Lint with tox run: tox -e lint # - name: Format with tox diff --git a/tox.ini b/tox.ini index 7e291f56..e320750c 100644 --- a/tox.ini +++ b/tox.ini @@ -8,7 +8,7 @@ envlist = [testenv:test] extras = test commands = - python -m pytest --cov --cov-report xml --cov-report term-missing --ignore=venv + - python -m pytest --cov --cov-report xml --cov-report term-missing --ignore=venv [testenv:lint] basepython = python3 From 00fae0b713400592eef7b51d0ecf967c938f4a8d Mon Sep 17 00:00:00 2001 From: Rodrigo Almeida Date: Mon, 31 Jan 2022 12:09:57 +0100 Subject: [PATCH 05/13] Add release Actions workflow (#449) * Uncomment tox * Update job name to test * Add release workflow only on main and with tag --- .github/workflows/release.yml | 31 +++++++++++++++++++++++++++++++ .github/workflows/tests.yml | 7 ++++--- 2 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..808568c7 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,31 @@ +name: Release Python package + +on: + workflow_run: + workflows: [tests] + branches: [main] + types: [completed] + +jobs: + release: + needs: test + runs-on: ubuntu-latest + name: Release package to PyPi + if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') + steps: + - uses: actions/checkout@master + - name: Set up Python 3.8 + uses: actions/setup-python@v1 + with: + python-version: 3.8 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install tox tox-gh-actions + - name: Build and release 📦 to PyPI + with: + TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }} + TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} + run: | + tox -e release + diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 3cf063fb..f37f10e1 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -4,7 +4,7 @@ on: - push jobs: - build: + test: runs-on: ubuntu-latest name: Docker | GDAL=${{ matrix.gdal-version }} | python=${{ matrix.python-version }} container: osgeo/gdal:ubuntu-small-${{ matrix.gdal-version }} @@ -45,9 +45,10 @@ jobs: python -m pip install tox - name: Lint with tox run: tox -e lint - # - name: Format with tox - # run: tox -e format + - name: Format with tox + run: tox -e format - name: Flake8 with tox run: tox -e flake8 - name: Test with tox run: tox -e test + From 92dd5e444236871bedd974704af1ea03145bfc41 Mon Sep 17 00:00:00 2001 From: Rodrigo Almeida Date: Tue, 1 Feb 2022 13:38:07 +0100 Subject: [PATCH 06/13] Fix flake8 (#450) * lint is flake8 * Remove - in order to not ignore exit code * Add extended ignores for flake8 * Rm unused vars * Remove extra # * Rm unused var * Add rio-cogeo dependency * Fix undefined variable, ignore ambigous name * Rm flake8 * Fix unused imports F401 --- .github/workflows/tests.yml | 2 -- docs/conf.py | 2 +- setup.py | 1 + solaris/__init__.py | 2 +- solaris/eval/__init__.py | 2 +- solaris/eval/base.py | 2 -- solaris/preproc/__init__.py | 2 +- solaris/preproc/image.py | 2 +- solaris/preproc/label.py | 2 +- solaris/preproc/optical.py | 3 +-- solaris/preproc/pipesegment.py | 2 +- solaris/preproc/sar.py | 3 +-- solaris/raster/__init__.py | 2 +- solaris/raster/image.py | 2 -- solaris/tile/__init__.py | 2 +- solaris/tile/raster_tile.py | 2 +- solaris/utils/__init__.py | 2 +- solaris/utils/tile.py | 6 ------ solaris/vector/__init__.py | 2 +- tests/test_cli/test_cli.py | 2 -- tests/test_data/test_coco.py | 4 ++-- tests/test_eval/evaluator_test.py | 1 - tests/test_imports.py | 1 + tests/test_raster/test_image.py | 5 +---- tox.ini | 25 ++++++++++--------------- 25 files changed, 29 insertions(+), 52 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f37f10e1..a6262baf 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -47,8 +47,6 @@ jobs: run: tox -e lint - name: Format with tox run: tox -e format - - name: Flake8 with tox - run: tox -e flake8 - name: Test with tox run: tox -e test diff --git a/docs/conf.py b/docs/conf.py index f0eeee2a..48a37a50 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -14,7 +14,7 @@ import sys sys.path.insert(0, os.path.abspath("..")) -import numpy as np +import numpy as np # noqa: F401 import sphinx_bootstrap_theme # -- Project information ----------------------------------------------------- diff --git a/setup.py b/setup.py index 33bd7914..3de8cd71 100644 --- a/setup.py +++ b/setup.py @@ -52,6 +52,7 @@ def check_output(cmd): "pyproj>=2.1", "PyYAML>=5.4", "rasterio>=1.0.23", + "rio-cogeo>=3.0.2", "requests==2.22.0", "rtree>=0.9.3", "scikit-image>=0.16.2", diff --git a/solaris/__init__.py b/solaris/__init__.py index e8e0fc12..cb4bdf79 100644 --- a/solaris/__init__.py +++ b/solaris/__init__.py @@ -1,4 +1,4 @@ -from . import data, utils, vector +from . import data, utils, vector # noqa: F401 # data, eval, preproc, raster, tile, have gdal in them need to replace with rasterio __version__ = "0.0.1" diff --git a/solaris/eval/__init__.py b/solaris/eval/__init__.py index f62093a2..dc24d18b 100644 --- a/solaris/eval/__init__.py +++ b/solaris/eval/__init__.py @@ -1 +1 @@ -from . import base, iou, pixel, vector +from . import base, iou, pixel, vector # noqa: F401 diff --git a/solaris/eval/base.py b/solaris/eval/base.py index 7bb8806a..53b08908 100644 --- a/solaris/eval/base.py +++ b/solaris/eval/base.py @@ -111,8 +111,6 @@ def eval_iou_spacenet_csv( scoring_dict_list = [] self.ground_truth_GDF[iou_field] = 0.0 iou_index = self.ground_truth_GDF.columns.get_loc(iou_field) - id_cols = 2 - ground_truth_ids = self.ground_truth_GDF.iloc[:, :id_cols] for imageID in tqdm(imageIDList): self.ground_truth_GDF_Edit = self.ground_truth_GDF[ diff --git a/solaris/preproc/__init__.py b/solaris/preproc/__init__.py index b3ce3174..bd0a804c 100644 --- a/solaris/preproc/__init__.py +++ b/solaris/preproc/__init__.py @@ -1 +1 @@ -from . import image, label, optical, pipesegment, sar +from . import image, label, optical, pipesegment, sar # noqa: F401 diff --git a/solaris/preproc/image.py b/solaris/preproc/image.py index f358493b..47bf4463 100644 --- a/solaris/preproc/image.py +++ b/solaris/preproc/image.py @@ -9,7 +9,7 @@ import pandas as pd from osgeo import gdal_array -from .pipesegment import LoadSegment, MergeSegment, PipeSegment +from .pipesegment import LoadSegment, PipeSegment class Image: diff --git a/solaris/preproc/label.py b/solaris/preproc/label.py index 1fe510a2..012f15c8 100644 --- a/solaris/preproc/label.py +++ b/solaris/preproc/label.py @@ -4,7 +4,7 @@ import shapely.wkt from ..vector.polygon import convert_poly_coords -from .pipesegment import LoadSegment, MergeSegment, PipeSegment +from .pipesegment import LoadSegment, PipeSegment class LoadString(LoadSegment): diff --git a/solaris/preproc/optical.py b/solaris/preproc/optical.py index f26bd352..44007483 100644 --- a/solaris/preproc/optical.py +++ b/solaris/preproc/optical.py @@ -2,9 +2,8 @@ import numpy as np -from . import image from .image import Image -from .pipesegment import LoadSegment, MergeSegment, PipeSegment +from .pipesegment import PipeSegment class RGBToHSL(PipeSegment): diff --git a/solaris/preproc/pipesegment.py b/solaris/preproc/pipesegment.py index 00c335c6..d0a88f98 100644 --- a/solaris/preproc/pipesegment.py +++ b/solaris/preproc/pipesegment.py @@ -412,7 +412,7 @@ def PipeFunction(inner_class=PipeSegment, pin=(), *args, **kwargs): and *args and **kwargs are sent to the PipeSegment's constructor. """ psobject = inner_class(*args, **kwargs) - if issubclass(self.inner_class, LoadSegment): + if issubclass(self.inner_class, LoadSegment): # noqa: F821 return psobject() else: return (pin * psobject)() diff --git a/solaris/preproc/sar.py b/solaris/preproc/sar.py index 23932bf3..a46add22 100644 --- a/solaris/preproc/sar.py +++ b/solaris/preproc/sar.py @@ -1,6 +1,5 @@ import json import math -import os import uuid import warnings import xml.etree.ElementTree as ET @@ -12,7 +11,7 @@ from . import image from .image import Image -from .pipesegment import LoadSegment, MergeSegment, PipeSegment +from .pipesegment import PipeSegment class BandMath(PipeSegment): diff --git a/solaris/raster/__init__.py b/solaris/raster/__init__.py index e82a84ad..be5d49c7 100644 --- a/solaris/raster/__init__.py +++ b/solaris/raster/__init__.py @@ -1 +1 @@ -from . import image +from . import image # noqa: F401 diff --git a/solaris/raster/image.py b/solaris/raster/image.py index 49237e26..cc751dc3 100644 --- a/solaris/raster/image.py +++ b/solaris/raster/image.py @@ -1,5 +1,3 @@ -import os - import numpy as np import rasterio diff --git a/solaris/tile/__init__.py b/solaris/tile/__init__.py index 08743baa..bfedeece 100644 --- a/solaris/tile/__init__.py +++ b/solaris/tile/__init__.py @@ -1 +1 @@ -from . import raster_tile, vector_tile +from . import raster_tile, vector_tile # noqa: F401 diff --git a/solaris/tile/raster_tile.py b/solaris/tile/raster_tile.py index 841c79b8..ea7a3dd2 100644 --- a/solaris/tile/raster_tile.py +++ b/solaris/tile/raster_tile.py @@ -5,10 +5,10 @@ from rasterio.mask import mask as rasterio_mask from rasterio.vrt import WarpedVRT from rasterio.warp import Resampling, calculate_default_transform +from rio_cogeo.cogeo import cog_translate # ,cog_validate from shapely.geometry import box from tqdm.auto import tqdm -# from rio_cogeo.cogeo import cog_validate, cog_translate from ..utils.core import _check_crs, _check_rasterio_im_load # removing the following until COG functionality is implemented diff --git a/solaris/utils/__init__.py b/solaris/utils/__init__.py index 1f7ae20a..49f839f8 100644 --- a/solaris/utils/__init__.py +++ b/solaris/utils/__init__.py @@ -1 +1 @@ -from . import cli, core, data, geo, io, tile +from . import cli, core, data, geo, io, tile # noqa: F401 diff --git a/solaris/utils/tile.py b/solaris/utils/tile.py index 06932eb3..3b34229e 100644 --- a/solaris/utils/tile.py +++ b/solaris/utils/tile.py @@ -1,11 +1,5 @@ import json -import geopandas as gpd -from affine import Affine -from rasterio.enums import Resampling -from rasterio.vrt import WarpedVRT -from rasterio.windows import Window - from .core import _check_crs # temporarily removing the below until I can get COG functionality implemented diff --git a/solaris/vector/__init__.py b/solaris/vector/__init__.py index 4323d396..9a4f4ccf 100644 --- a/solaris/vector/__init__.py +++ b/solaris/vector/__init__.py @@ -1 +1 @@ -from . import graph, mask, polygon +from . import graph, mask, polygon # noqa: F401 diff --git a/tests/test_cli/test_cli.py b/tests/test_cli/test_cli.py index ff74fddd..94f35cd9 100644 --- a/tests/test_cli/test_cli.py +++ b/tests/test_cli/test_cli.py @@ -1,8 +1,6 @@ import os -import pickle import subprocess -import networkx as nx import numpy as np import skimage.io diff --git a/tests/test_data/test_coco.py b/tests/test_data/test_coco.py index 02494667..f7c91ba9 100644 --- a/tests/test_data/test_coco.py +++ b/tests/test_data/test_coco.py @@ -23,7 +23,7 @@ def test_multiclass_single_geojson(self): expected_dict = json.load(f) with open(os.path.join(data_dir, "tmp_coco.json"), "r") as f: saved_result = json.load(f) - ## Simplified test due to rounding errors- JSS + # Simplified test due to rounding errors- JSS assert ( coco_dict["annotations"][0]["bbox"] == expected_dict["annotations"][0]["bbox"] @@ -62,7 +62,7 @@ def test_singleclass_multi_geojson(self): with open(os.path.join(data_dir, "coco_sample_1.json"), "r") as f: expected_dict = json.load(f) - ## Simplified test due to rounding errors- JSS + # Simplified test due to rounding errors- JSS assert ( expected_dict["annotations"][0]["bbox"] == coco_dict["annotations"][0]["bbox"] diff --git a/tests/test_eval/evaluator_test.py b/tests/test_eval/evaluator_test.py index 0c52087f..6355cfca 100644 --- a/tests/test_eval/evaluator_test.py +++ b/tests/test_eval/evaluator_test.py @@ -86,7 +86,6 @@ def test_iou_by_building(self): path_truth = os.path.join(data_folder, "SN2_sample_truth.csv") path_pred = os.path.join(data_folder, "SN2_sample_preds.csv") path_ious = os.path.join(data_folder, "SN2_sample_iou_by_building.csv") - path_temp = "./temp.pd" eb = Evaluator(path_truth) eb.load_proposal(path_pred, conf_field_list=["Confidence"], proposalCSV=True) eb.eval_iou_spacenet_csv(miniou=0.5, imageIDField="ImageId", min_area=20) diff --git a/tests/test_imports.py b/tests/test_imports.py index 72e52305..144606cf 100644 --- a/tests/test_imports.py +++ b/tests/test_imports.py @@ -1,3 +1,4 @@ +# flake8: noqa: F401 class TestImports(object): def test_imports(self): import solaris diff --git a/tests/test_raster/test_image.py b/tests/test_raster/test_image.py index 02527d9a..4b4e0a64 100644 --- a/tests/test_raster/test_image.py +++ b/tests/test_raster/test_image.py @@ -1,12 +1,9 @@ import os -import numpy as np -import skimage.io from affine import Affine -import solaris as sol from solaris.data import sample_load_rasterio -from solaris.raster.image import get_geo_transform, stitch_images +from solaris.raster.image import get_geo_transform data_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), "../data/")) diff --git a/tox.ini b/tox.ini index e320750c..72f30073 100644 --- a/tox.ini +++ b/tox.ini @@ -2,7 +2,6 @@ envlist = lint, format, - flake8, test [testenv:test] @@ -13,19 +12,9 @@ commands = [testenv:lint] basepython = python3 skip_install = true -deps = - isort - black -commands = - - isort --check-only --df . - - black --check --diff --color . - -[testenv:flake8] -basepython = python3 -skip_install = true deps = flake8 commands = - - flake8 + flake8 . [testenv:format] basepython = python3 @@ -34,8 +23,8 @@ deps = isort black commands = - - isort . - - black . + isort . + black . [testenv:build] basepython = python3 @@ -61,7 +50,12 @@ commands = [flake8] extend-ignore = - E203, + E203, # whitespace before ':' + E501, # line too long + C901, # is too complex + E402, # module level import not at top of file (for docs) + E741, # ambiguous variable name + exclude = .git, __pycache__, @@ -72,6 +66,7 @@ exclude = .tox max-line-length = 88 max-complexity = 10 +count=true [isort] profile = black From 553eed0dfe569b99398a3e9d76a3b4cf209675ef Mon Sep 17 00:00:00 2001 From: Rodrigo Almeida Date: Tue, 1 Feb 2022 13:42:03 +0100 Subject: [PATCH 07/13] Remove - --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 72f30073..0a6dd382 100644 --- a/tox.ini +++ b/tox.ini @@ -7,7 +7,7 @@ envlist = [testenv:test] extras = test commands = - - python -m pytest --cov --cov-report xml --cov-report term-missing --ignore=venv + python -m pytest --cov --cov-report xml --cov-report term-missing --ignore=venv [testenv:lint] basepython = python3 From 4f0670ca7bbb181673f8f073b12fa433e35da361 Mon Sep 17 00:00:00 2001 From: Rodrigo Almeida Date: Tue, 1 Feb 2022 13:48:57 +0100 Subject: [PATCH 08/13] Add cv2 dependencies --- .github/workflows/tests.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a6262baf..3eb64408 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -38,7 +38,8 @@ jobs: python${{ matrix.python-version }}-dev \ python${{ matrix.python-version }}-venv \ python3-pip \ - g++ + g++ \ + libgl1 - name: Install dependencies run: | python -m pip install --upgrade pip From 752bf3425c896fb89bb18014a48db902e6dd87e2 Mon Sep 17 00:00:00 2001 From: Rodrigo Almeida Date: Tue, 1 Feb 2022 13:55:35 +0100 Subject: [PATCH 09/13] Format --- docs/conf.py | 2 +- setup.py | 2 +- solaris/preproc/sar.py | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 48a37a50..a305b14f 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -25,7 +25,7 @@ license = "MIT" import time -copyright = u"2018-{}, CosmiQ Works: an IQT Lab".format(time.strftime("%Y")) +copyright = "2018-{}, CosmiQ Works: an IQT Lab".format(time.strftime("%Y")) # The full version, including alpha/beta/rc tags release = "0.0.1" diff --git a/setup.py b/setup.py index 3de8cd71..f79b7cd6 100644 --- a/setup.py +++ b/setup.py @@ -80,7 +80,7 @@ def check_output(cmd): "Programming Language :: Python :: 3.10", "Topic :: Scientific/Engineering :: GIS", ], - author=u"Ryan Avery", + author="Ryan Avery", author_email="ryan@developmentseed.org", url="https://github.com/CosmiQ/solaris", license="MIT", diff --git a/solaris/preproc/sar.py b/solaris/preproc/sar.py index a46add22..2e5942d8 100644 --- a/solaris/preproc/sar.py +++ b/solaris/preproc/sar.py @@ -667,8 +667,8 @@ def fineoffset(self, latgrid, longrid, lattarget, lontarget, uidx, vidx): ulon = longrid[uidx + 1, vidx] - longrid[uidx, vidx] vlat = latgrid[uidx, vidx + 1] - latgrid[uidx, vidx] vlon = longrid[uidx, vidx + 1] - longrid[uidx, vidx] - uoffset = (mlat * ulat + mlon * ulon) / (ulat ** 2 + ulon ** 2) - voffset = (mlat * vlat + mlon * vlon) / (vlat ** 2 + vlon ** 2) + uoffset = (mlat * ulat + mlon * ulon) / (ulat**2 + ulon**2) + voffset = (mlat * vlat + mlon * vlon) / (vlat**2 + vlon**2) return uoffset, voffset From 71d416cfbfd539ebfc986dcc15489d430151b5c6 Mon Sep 17 00:00:00 2001 From: Rodrigo Almeida Date: Tue, 1 Feb 2022 13:55:51 +0100 Subject: [PATCH 10/13] Check if formatting passes --- tox.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tox.ini b/tox.ini index 0a6dd382..9576088d 100644 --- a/tox.ini +++ b/tox.ini @@ -23,8 +23,8 @@ deps = isort black commands = - isort . - black . + isort . -c + black . --check [testenv:build] basepython = python3 From 6e8f13603ce1e34c5ac146e55fa6ff08e54a9c94 Mon Sep 17 00:00:00 2001 From: Rodrigo Almeida Date: Tue, 1 Feb 2022 15:40:56 +0100 Subject: [PATCH 11/13] Move black/isort/flake8 config to setup.cfg --- setup.cfg | 27 +++++++++++++++++++++++++++ tox.ini | 28 ---------------------------- 2 files changed, 27 insertions(+), 28 deletions(-) create mode 100644 setup.cfg diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 00000000..42ca1a0e --- /dev/null +++ b/setup.cfg @@ -0,0 +1,27 @@ +[flake8] +extend-ignore = + E203, # whitespace before ':' + E501, # line too long + C901, # is too complex + E402, # module level import not at top of file (for docs) + E741, # ambiguous variable name + +exclude = + .git, + __pycache__, + docs/source/conf.py, + old, + build, + dist, + .tox +max-line-length = 88 +max-complexity = 10 +count=true + +[isort] +profile = black + +[black] +line-length = 88 +target-version = ['py37', 'py38', 'py39', 'py310'] +experimental_string_processing = true \ No newline at end of file diff --git a/tox.ini b/tox.ini index 9576088d..b3aad950 100644 --- a/tox.ini +++ b/tox.ini @@ -47,31 +47,3 @@ deps = commands = {[testenv:build]commands} twine upload --skip-existing dist/* - -[flake8] -extend-ignore = - E203, # whitespace before ':' - E501, # line too long - C901, # is too complex - E402, # module level import not at top of file (for docs) - E741, # ambiguous variable name - -exclude = - .git, - __pycache__, - docs/source/conf.py, - old, - build, - dist, - .tox -max-line-length = 88 -max-complexity = 10 -count=true - -[isort] -profile = black - -[black] -line-length = 88 -target-version = ['py37', 'py38', 'py39', 'py310'] -experimental_string_processing = true \ No newline at end of file From ce33b9fa32d6910e6af6fd152e9a234f993b66da Mon Sep 17 00:00:00 2001 From: Rodrigo Almeida Date: Tue, 1 Feb 2022 17:41:15 +0100 Subject: [PATCH 12/13] Add pre-commit config with isort, balck and flake8 --- .pre-commit-config.yaml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..59f21159 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,14 @@ +repos: +- repo: https://github.com/pycqa/isort + rev: 5.10.1 + hooks: + - id: isort +- repo: https://github.com/ambv/black + rev: 22.1.0 + hooks: + - id: black + language_version: python3.9 +- repo: https://gitlab.com/pycqa/flake8 + rev: 3.9.2 + hooks: + - id: flake8 From 8412a0d455d531da63af636daa91ebc1acaa605c Mon Sep 17 00:00:00 2001 From: Rodrigo Almeida Date: Tue, 8 Feb 2022 12:23:42 +0100 Subject: [PATCH 13/13] Add pre-commit dep --- requirements-test.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements-test.txt b/requirements-test.txt index 98deecb8..a2d2c963 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -22,3 +22,4 @@ pytest tox isort flake8 +pre-commit \ No newline at end of file