Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ruff proposal #156

Draft
wants to merge 4 commits into
base: ruff
Choose a base branch
from
Draft

Ruff proposal #156

wants to merge 4 commits into from

Conversation

jhkennedy
Copy link
Contributor

This updates ruff config in-line with the updates to the ruff action proposed in ASFHyP3/actions#95 and applies the lining auto fixes.

In particular, adopting the additional checks would result in needing to make quite a few changes to satisfy the linter:

$ ruff check --statistics .
56      ANN001  [ ] Missing type annotation for function argument `array`
56      ANN201  [ ] Missing return type annotation for public function `check_correctness_of_resample`
55      D103    [ ] Missing docstring in public function
32      D415    [*] First line should end with a period, question mark, or exclamation point
20      D100    [ ] Missing docstring in public module
13      PTH123  [ ] `open()` should be replaced by `Path.open()`
10      ANN101  [ ] Missing type annotation for `self` in method
 8      D205    [ ] 1 blank line required between summary line and description
 6      ANN204  [ ] Missing return type annotation for special method `__enter__`
 3      PTH107  [ ] `os.remove()` should be replaced by `Path.unlink()`
 3      D107    [ ] Missing docstring in `__init__`
 2      PTH113  [ ] `os.path.isfile()` should be replaced by `Path.is_file()`
 2      D105    [ ] Missing docstring in magic method
 2      D200    [*] One-line docstring should fit on one line
 2      D417    [ ] Missing argument description in the docstring for `create_water_mask`: `input_image`
 1      ANN003  [ ] Missing type annotation for `**options`
 1      ANN202  [ ] Missing return type annotation for private function `_download_platform`
 1      PTH109  [ ] `os.getcwd()` should be replaced by `Path.cwd()`
 1      PTH120  [ ] `os.path.dirname()` should be replaced by `Path.parent`
 1      PTH207  [ ] Replace `glob` with `Path.glob` or `Path.rglob`
 1      D104    [ ] Missing docstring in public package

Copy link
Contributor

github-actions bot commented Nov 10, 2023

Coverage

Coverage Report
FileStmtsMissCoverMissing
/home/runner/micromamba/envs/hyp3-isce2/lib/python3.11/site-packages/hyp3_isce2
   __main__.py26292%32, 43
   burst.py1705170%78–81, 94–99, 113–128, 144–153, 167–177, 235, 282–290, 310–324
   dem.py53394%103–112
   insar_stripmap.py694239%38–91, 95–97, 113–132
   insar_tops.py502844%42–75, 96–116
   insar_tops_burst.py20115921%72–146, 158–184, 212–290, 301–383, 423–503
   logging.py4175%9
   s1_auxcal.py21290%51, 59
   slc.py341071%22–25, 29–34
   stripmapapp_alos.py50786%103, 139, 142–147
   topsapp.py69888%76, 106, 128–134
   utils.py773061%103–105, 118–126, 138–143, 187–200, 210–214, 226–227
/home/runner/micromamba/envs/hyp3-isce2/lib/python3.11/site-packages/hyp3_isce2/metadata
   util.py14936%6–14, 18–21, 25–27
TOTAL90135261% 

Tests Skipped Failures Errors Time
42 0 💤 0 ❌ 0 🔥 29.781s ⏱️

@@ -177,7 +177,7 @@ def download_burst(asf_session: requests.Session, burst_params: BurstParams, out
return Path(out_file)


def spoof_safe(burst: BurstMetadata, burst_tiff_path: Path, base_path: Path = Path('.')) -> Path:
def spoof_safe(burst: BurstMetadata, burst_tiff_path: Path, base_path: Path = Path.cwd()) -> Path:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ruff does not like Path('.') and would prefer you use either Path() or Path.cwd(). There were some gotcha's here around when '.' was resolved to an actual path, so we'll want to make sure that Path.cwd() doesn't hit those again....

@@ -123,7 +123,7 @@ def run_stripmapapp(dostep: str = '', start: str = '', end: str = '', config_xml
ValueError: If the step is not a valid step (see TOPSAPP_STEPS)
"""
if not config_xml.exists():
raise IOError(f'The config file {config_xml} does not exist!')
raise OSError(f'The config file {config_xml} does not exist!')
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IOError is just a legacy/backwards compatible alias for OSError so OSError is preferred.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant