Skip to content

Commit

Permalink
Merge pull request #372 from jhkennedy/ruff
Browse files Browse the repository at this point in the history
Switch to Ruff
  • Loading branch information
jhkennedy authored Nov 30, 2023
2 parents 5e6b859 + 7ed8385 commit d6fe7f8
Show file tree
Hide file tree
Showing 14 changed files with 90 additions and 169 deletions.
3 changes: 0 additions & 3 deletions .flake8

This file was deleted.

27 changes: 27 additions & 0 deletions .github/workflows/static-analysis.yml
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):
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

0 comments on commit d6fe7f8

Please sign in to comment.