Skip to content

Commit

Permalink
Isolate protected import for pyright
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanjmcdougall committed Aug 21, 2024
1 parent 534a1ea commit c021871
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions pins/drivers.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,14 @@ def load_data(
elif meta.type == "rds":
try:
import rdata

# Equivalent to `rdata.read_rds(f)` but compatible with Python 3.8.
# See https://github.com/rstudio/pins-python/pull/265
parsed = rdata.parser.parse_file(f.name)
return rdata.conversion.convert(parsed)
except ModuleNotFoundError:
raise ModuleNotFoundError(
"Install the 'rdata' package to attempt to convert 'rds' files into Python objects."

Check failure on line 128 in pins/drivers.py

View workflow job for this annotation

GitHub Actions / Run Pyright

Import "rdata" could not be resolved (reportMissingImports)
)
# Equivalent to `rdata.read_rds(f)` but compatible with Python 3.8.
# See https://github.com/rstudio/pins-python/pull/265
parsed = rdata.parser.parse_file(f.name)
return rdata.conversion.convert(parsed)

raise NotImplementedError(f"No driver for type {meta.type}")

Expand Down

0 comments on commit c021871

Please sign in to comment.