Skip to content

Commit

Permalink
change default reader_options to None (#137)
Browse files Browse the repository at this point in the history
* change default reader_options to None

* ruff
  • Loading branch information
TomNicholas authored Jun 13, 2024
1 parent 61891d3 commit dc62090
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
13 changes: 8 additions & 5 deletions virtualizarr/kerchunk.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import json
from enum import Enum, auto
from pathlib import Path
from typing import NewType, Optional, cast
from typing import Any, NewType, Optional, cast

import numpy as np
import ujson # type: ignore
Expand Down Expand Up @@ -53,9 +53,7 @@ def default(self, obj):
def read_kerchunk_references_from_file(
filepath: str,
filetype: FileType | None,
reader_options: Optional[dict] = {
"storage_options": {"key": "", "secret": "", "anon": True}
},
reader_options: Optional[dict[str, Any]] = None,
) -> KerchunkStoreRefs:
"""
Read a single legacy file and return kerchunk references to its contents.
Expand All @@ -77,6 +75,9 @@ def read_kerchunk_references_from_file(
filepath=filepath, reader_options=reader_options
)

if reader_options is None:
reader_options = {}

# if filetype is user defined, convert to FileType
filetype = FileType(filetype)

Expand Down Expand Up @@ -111,7 +112,9 @@ def read_kerchunk_references_from_file(


def _automatically_determine_filetype(
*, filepath: str, reader_options: Optional[dict] = {}
*,
filepath: str,
reader_options: Optional[dict[str, Any]] = None,
) -> FileType:
file_extension = Path(filepath).suffix
fpath = _fsspec_openfile_from_filepath(
Expand Down
3 changes: 3 additions & 0 deletions virtualizarr/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ def _fsspec_openfile_from_filepath(
else:
protocol_defaults = {}

if reader_options is None:
reader_options = {}

storage_options = reader_options.get("storage_options", {}) # type: ignore

# using dict merge operator to add in defaults if keys are not specified
Expand Down

0 comments on commit dc62090

Please sign in to comment.