Skip to content

Commit 4e3b356

Browse files
committed
ruff ruff
1 parent a06a390 commit 4e3b356

File tree

6 files changed

+43
-43
lines changed

6 files changed

+43
-43
lines changed

docs/conf.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import os
1212
import sys
1313

14-
sys.path.insert(0, os.path.abspath('../src'))
14+
sys.path.insert(0, os.path.abspath("../src"))
1515

1616
# -- Project information -----------------------------------------------------
1717
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
@@ -27,16 +27,16 @@
2727
"sphinx.ext.napoleon",
2828
"sphinx.ext.autodoc",
2929
"sphinx.ext.autosummary",
30-
"sphinx_rtd_theme"
30+
"sphinx_rtd_theme",
3131
]
3232

3333
autosummary_generate = True
3434

3535
templates_path = ["_templates"]
36-
exclude_patterns = ['_build', '_templates']
36+
exclude_patterns = ["_build", "_templates"]
3737

3838

3939
# -- Options for HTML output -------------------------------------------------
4040
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
4141

42-
html_theme = "sphinx_rtd_theme"
42+
html_theme = "sphinx_rtd_theme"

src/stac_utils/benchmark.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,9 @@ def make_msg(msg: str, t: float) -> str:
4646
h, m = divmod(m, 60)
4747
d, h = divmod(h, 24)
4848
if d:
49-
msg = (
50-
f"{msg}: {d:.0f} days, " f"{h:.0f} hours, {m:.0f} minutes, {s:.0f} seconds"
51-
)
49+
msg = f"{msg}: {d:.0f} days, {h:.0f} hours, {m:.0f} minutes, {s:.0f} seconds"
5250
elif h:
53-
msg = f"{msg}: " f"{h:.0f} hours, {m:.0f} minutes, {s:.0f} seconds"
51+
msg = f"{msg}: {h:.0f} hours, {m:.0f} minutes, {s:.0f} seconds"
5452
elif m:
5553
msg = f"{msg}: {m:.0f} minutes, {s:.0f} seconds"
5654
else:

src/stac_utils/browser/driver.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,15 @@ def __enter__(self):
6060
options.add_argument("--window-size=1280x1696")
6161
options.add_argument("--disable-dev-shm-usage")
6262
options.add_argument("--disable-dev-tools")
63-
options.add_argument("--disable-blink-features=AutomationControlled")
63+
options.add_argument("--disable-blink-features=AutomationControlled")
6464
options.add_argument("--no-zygote")
6565
options.add_argument(f"--user-data-dir={tempfile.mkdtemp()}")
6666
options.add_argument(f"--data-path={tempfile.mkdtemp()}")
6767
options.add_argument(f"--disk-cache-dir={tempfile.mkdtemp()}")
6868
options.add_experimental_option(
6969
"prefs", {"download.default_directory": self.download_directory}
7070
)
71-
options.add_experimental_option("useAutomationExtension", False)
71+
options.add_experimental_option("useAutomationExtension", False)
7272

7373
self.driver = webdriver.Chrome(service=service, options=options)
7474

@@ -77,7 +77,9 @@ def __enter__(self):
7777
"""
7878
self.driver.download_directory = self.download_directory
7979

80-
self.driver.execute_script("Object.defineProperty(navigator, 'webdriver', {get: () => undefined})")
80+
self.driver.execute_script(
81+
"Object.defineProperty(navigator, 'webdriver', {get: () => undefined})"
82+
)
8183

8284
return self.driver
8385

src/stac_utils/google.py

+28-28
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,7 @@ def send_data_to_sheets(
528528
:param input_option: Specified input option, `RAW` by default
529529
:param client: Google Sheets client
530530
:param is_overwrite: Overwrite option, defaults to `True`
531+
:param is_fill_in_nulls: replace nulls with blanks, default to `False`
531532
:return: Google Sheets API response
532533
"""
533534

@@ -602,21 +603,25 @@ def copy_file(file_id: str, new_file_name: str = None, client: Resource = None)
602603

603604
return new_file_id
604605

605-
def upload_file_to_drive(local_path: str,
606-
gdrive_file_name: str,
607-
existing_mime_type = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
608-
gdrive_mime_type = 'application/vnd.google-apps.spreadsheet',
609-
permissions = [{
610-
"type": "domain",
611-
"role": "reader",
612-
"domain": "staclabs.io",
613-
}],
614-
client: Resource = None
615-
) -> str:
616-
"""
617-
Uploads a local file to Google Drive.
618-
619-
By default, it uploads an Excel file and converts it to a Google Sheet. Specify the
606+
607+
def upload_file_to_drive(
608+
local_path: str,
609+
gdrive_file_name: str,
610+
existing_mime_type="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
611+
gdrive_mime_type="application/vnd.google-apps.spreadsheet",
612+
permissions=[
613+
{
614+
"type": "domain",
615+
"role": "reader",
616+
"domain": "staclabs.io",
617+
}
618+
],
619+
client: Resource = None,
620+
) -> str:
621+
"""
622+
Uploads a local file to Google Drive.
623+
624+
By default, it uploads an Excel file and converts it to a Google Sheet. Specify the
620625
Mime Type parameters if you want to upload a CSV to a Google Sheet, a Word doc to a
621626
Google Doc, etc.
622627
@@ -628,25 +633,20 @@ def upload_file_to_drive(local_path: str,
628633
:param gdrive_file_name: Name we should give the uploaded file
629634
:param existing_mime_type: Mime type of the local file (defaults to Excel)
630635
:param gdrive_mime_type: Mime type of the resulting file (defaults to Google Sheets)
631-
:param permissions: Array of Google permissions objects specifying who should access the
636+
:param permissions: Array of Google permissions objects specifying who should access the
632637
new file. Defaults to giving everyone at stac labs read-only permissions.
633638
:param client: Google Drive client
634639
:return: id of the file on Google drive
635640
"""
636641
client = client or auth_drive()
637-
file_metadata = {
638-
"name": gdrive_file_name,
639-
"mimeType": gdrive_mime_type
640-
}
641-
media = MediaFileUpload(local_path,
642-
mimetype=existing_mime_type,
643-
resumable=True)
642+
file_metadata = {"name": gdrive_file_name, "mimeType": gdrive_mime_type}
643+
media = MediaFileUpload(local_path, mimetype=existing_mime_type, resumable=True)
644644
file = (
645-
client.files()
646-
.create(body=file_metadata, media_body=media, fields="id")
647-
.execute()
648-
)
649-
fileId = file['id']
645+
client.files()
646+
.create(body=file_metadata, media_body=media, fields="id")
647+
.execute()
648+
)
649+
fileId = file["id"]
650650

651651
batch = client.new_batch_http_request()
652652
for perm in permissions:

src/stac_utils/reach.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class ReachClient(HTTPClient):
1818
api_user: username, will pick up "REACH_API_USER" if it's in the environment
1919
api_password: password, will pick up "REACH_API_PASSWORD" if it's in the environment
2020
"""
21-
21+
2222
base_url = "https://api.reach.vote/api/v1"
2323

2424
def __init__(self, api_user: str = None, api_password: str = None, *args, **kwargs):

src/tests/test_google.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -530,9 +530,9 @@ def test_text_stream_from_drive_with_client(
530530
mock_download_complete = MagicMock(progress=lambda: 1)
531531

532532
# downloader start case (at 1)
533-
mock_downloader.next_chunk.return_value[0].progress.return_value = (
534-
mock_download_progress
535-
)
533+
mock_downloader.next_chunk.return_value[
534+
0
535+
].progress.return_value = mock_download_progress
536536

537537
# side effect to handle downloader range
538538
# ("if side_effect is an iterable then each call to the mock will return the next value from the iterable")

0 commit comments

Comments
 (0)