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

Switch to Ruff #372

Merged
merged 11 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .flake8

This file was deleted.

27 changes: 27 additions & 0 deletions .github/workflows/static-analysis.yml
Copy link
Collaborator Author

@jhkennedy jhkennedy Nov 30, 2023

Choose a reason for hiding this comment

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

Looks like this workflow doesn't run here b/c it was added on a fork -- you can see it run in my fork here:
https://github.com/jhkennedy/earthdata/actions/workflows/static-analysis.yml

I added this in addition to it in the pre-commit because it will annotate the PR, which you can see in this PR:
https://github.com/ASFHyP3/hyp3-isce2/pull/156/files

Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Lint and Format with Ruff

on: push

jobs:
check-with-ruff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install Python
uses: actions/setup-python@v4
with:
python-version: 3.x

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install ruff

- name: Ruff linting check
run: |
ruff check --output-format=github .

- name: Ruff format check
run: |
ruff format --diff .
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ build/
*.egg-info/
docs/tutorials/data
tests/integration/data
.ruff_cache

# OS X
.DS_Store
Expand Down
8 changes: 5 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ repos:
- id: trailing-whitespace
- id: check-toml
- id: check-json
- repo: https://github.com/psf/black
rev: 23.10.1
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.6
hooks:
- id: black
- id: ruff
args: ["--fix", "--exit-non-zero-on-fix"]
- id: ruff-format
1 change: 0 additions & 1 deletion earthaccess/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import logging
import threading
from importlib.metadata import version
from typing import Any

from .api import (
auth_environ,
Expand Down
3 changes: 2 additions & 1 deletion earthaccess/api.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from typing import Any, Dict, List, Optional, Type, Union

import earthaccess
import requests
import s3fs
from fsspec import AbstractFileSystem

import earthaccess

from .auth import Auth
from .results import DataGranule
from .search import CollectionQuery, DataCollections, DataGranules, GranuleQuery
Expand Down
22 changes: 5 additions & 17 deletions earthaccess/daac.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,23 +110,11 @@

# Some testing urls behind EDL
DAAC_TEST_URLS = [
(
"https://archive.podaac.earthdata.nasa.gov/podaac-ops-cumulus-protected/"
"JASON_CS_S6A_L2_ALT_LR_STD_OST_NRT_F/"
),
(
"https://data.nsidc.earthdatacloud.nasa.gov/nsidc-cumulus-prod-protected/ATLAS/"
"ATL03/005/2018/10/14/dummy.nc"
),
(
"https://n5eil01u.ecs.nsidc.org/DP7/ATLAS/ATL06.005/2018.10.14/"
"ATL06_20181014045341_02380102_005_01.iso.xml"
),
("https://hydro1.gesdisc.eosdis.nasa.gov/data/GLDAS/GLDAS_NOAH10_M.2.0/1948/"),
(
"https://e4ftl01.cr.usgs.gov//DP114/MOTA/MCD43A3.006/2000.02.24/"
"MCD43A3.A2000055.h15v07.006.2016101151720.hdf.xml"
),
"https://archive.podaac.earthdata.nasa.gov/podaac-ops-cumulus-protected/JASON_CS_S6A_L2_ALT_LR_STD_OST_NRT_F/",
"https://data.nsidc.earthdatacloud.nasa.gov/nsidc-cumulus-prod-protected/ATLAS/ATL03/005/2018/10/14/dummy.nc",
"https://n5eil01u.ecs.nsidc.org/DP7/ATLAS/ATL06.005/2018.10.14/ATL06_20181014045341_02380102_005_01.iso.xml",
"https://hydro1.gesdisc.eosdis.nasa.gov/data/GLDAS/GLDAS_NOAH10_M.2.0/1948/",
"https://e4ftl01.cr.usgs.gov//DP114/MOTA/MCD43A3.006/2000.02.24/MCD43A3.A2000055.h15v07.006.2016101151720.hdf.xml",
"https://daac.ornl.gov/daacdata/npp/grassland/NPP_BCN/data/bcn_cli.txt",
]

Expand Down
4 changes: 1 addition & 3 deletions earthaccess/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,7 @@ def __repr__(self) -> str:
Temporal coverage: {self['umm']['TemporalExtent']}
Size(MB): {self.size()}
Data: {data_links}\n\n
""".strip().replace(
" ", ""
)
""".strip().replace(" ", "")
return rep_str

def _repr_html_(self) -> str:
Expand Down
5 changes: 3 additions & 2 deletions earthaccess/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@
from typing import Any, Dict, List, Optional, Union
from uuid import uuid4

import earthaccess
import fsspec
import requests
import s3fs
from multimethod import multimethod as singledispatchmethod
from pqdm.threads import pqdm

import earthaccess

from .auth import Auth
from .daac import DAAC_TEST_URLS, find_provider
from .results import DataGranule
Expand Down Expand Up @@ -51,7 +52,7 @@ def _open_files(
) -> List[fsspec.AbstractFileSystem]:
def multi_thread_open(data: tuple) -> EarthAccessFile:
urls, granule = data
if type(granule) is not str:
if not isinstance(granule, str):
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

$ ruff check earthaccess tests
earthaccess/store.py:55:12: E721 Do not compare types, use `isinstance()`

if len(granule.data_links()) > 1:
print(
"Warning: This collection contains more than one file per granule. "
Expand Down
157 changes: 28 additions & 129 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading