Skip to content

Commit

Permalink
switch to ruff from flake8
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewPlayer3 committed Dec 16, 2024
1 parent 92d6405 commit fc2fcd6
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 18 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ jobs:
# Docs: https://github.com/ASFHyP3/actions
uses: ASFHyP3/actions/.github/workflows/[email protected]

call-flake8-workflow:
call-ruff-workflow:
# Docs: https://github.com/ASFHyP3/actions
uses: ASFHyP3/actions/.github/workflows/[email protected]
with:
local_package_names: hyp3lib
uses: ASFHyP3/actions/.github/workflows/[email protected]
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [PEP 440](https://www.python.org/dev/peps/pep-0440/)
and uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [3.1.3]

### Changed
- The [`static-analysis`](.github/workflows/static-analysis.yml) Github Actions workflow now uses `ruff` rather than `flake8` for linting.

## [3.1.2]

### Fixed
Expand Down
5 changes: 1 addition & 4 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ dependencies:
- urllib3
# For packaging, and testing
- python-build
- flake8
- flake8-import-order
- flake8-blind-except
- flake8-builtins
- ruff
- setuptools
- setuptools_scm
- pytest
Expand Down
5 changes: 1 addition & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,7 @@ dynamic = ["version"]
[project.optional-dependencies]
develop = [
"botocore",
"flake8",
"flake8-import-order",
"flake8-blind-except",
"flake8-builtins",
"ruff",
"pytest",
"pytest-cov",
"pytest-console-scripts",
Expand Down
4 changes: 4 additions & 0 deletions ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
line-length = 120

[format]
quote-style = "single"
1 change: 1 addition & 0 deletions src/hyp3lib/SLC_copy_S1_fullSW.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""re-process S1 SLC imagery into gamma format SLCs"""

import argparse
import logging
import os
Expand Down
6 changes: 3 additions & 3 deletions src/hyp3lib/asf_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def cut_blackfill(data, geoTrans):
colFirst = rowProfile.index(1)
originX += colFirst * pixelSize
originY -= rowFirst * pixelSize
data = data[rowFirst:rows + rowFirst, colFirst:cols + colFirst]
data = data[rowFirst : rows + rowFirst, colFirst : cols + colFirst]
geoTrans = (originX, pixelSize, 0, originY, 0, -pixelSize)

return (data, colFirst, rowFirst, geoTrans)
Expand Down Expand Up @@ -283,7 +283,7 @@ def data_geometry2shape_ext(data, fields, values, spatialRef, geoTrans, classes,
originY = geoTrans[3] + 10 * pixelSize
geoTrans = (originX, pixelSize, 0, originY, 0, -pixelSize)
mask = np.zeros((rows + 20, cols + 20), dtype=np.float32)
mask[10:rows + 10, 10:cols + 10] = data
mask[10 : rows + 10, 10 : cols + 10] = data
data = mask

# Save in memory
Expand Down Expand Up @@ -647,7 +647,7 @@ def apply_mask(data, dataGeoTrans, mask, maskGeoTrans):
maskPixelSize = maskGeoTrans[1]
offsetX = int(np.rint((maskOriginX - dataOriginX) / maskPixelSize))
offsetY = int(np.rint((dataOriginY - maskOriginY) / maskPixelSize))
data = data[offsetY:maskRows + offsetY, offsetX:maskCols + offsetX]
data = data[offsetY : maskRows + offsetY, offsetX : maskCols + offsetX]
data *= mask

return data
Expand Down
1 change: 1 addition & 0 deletions src/hyp3lib/byteSigmaScale.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Convert a floating point tiff into a byte tiff using 2-sigma scaling."""

import argparse
import os

Expand Down
1 change: 1 addition & 0 deletions src/hyp3lib/createAmp.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Convert Geotiff Power to Amplitude"""

import argparse
import os

Expand Down
1 change: 1 addition & 0 deletions src/hyp3lib/fetch.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Utilities for fetching things from external endpoints"""

import logging
from email.message import Message
from os.path import basename
Expand Down
8 changes: 5 additions & 3 deletions tests/test_get_orb.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,11 @@ def test_download_sentinel_orbit_file_esa(tmp_path):
match=[responses.matchers.header_matcher({'Authorization': 'Bearer test-token'})],
)

with patch('hyp3lib.get_orb.get_orbit_url', return_value='https://foo.bar/hello.txt'), patch(
'hyp3lib.get_orb.EsaToken.__enter__', return_value='test-token'
), patch('hyp3lib.get_orb.EsaToken.__exit__'):
with (
patch('hyp3lib.get_orb.get_orbit_url', return_value='https://foo.bar/hello.txt'),
patch('hyp3lib.get_orb.EsaToken.__enter__', return_value='test-token'),
patch('hyp3lib.get_orb.EsaToken.__exit__'),
):
orbit_file, provider = get_orb.downloadSentinelOrbitFile(
_GRANULE,
providers=('ESA',),
Expand Down

0 comments on commit fc2fcd6

Please sign in to comment.