allenai / cached_path

A file utility for accessing both local and remote files through a unified interface.

Home Page:https://cached-path.readthedocs.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

1.1.0 breaks the user expansion convention against 1.0.2

zxteloiv opened this issue · comments

Checklist

  • I have verified that the issue exists against the main branch.
  • I have read the relevant section in the contribution guide on reporting bugs.
  • I have checked the issues list for similar or identical bug reports.
  • I have checked the pull requests list for existing proposed fixes.
  • I have checked the CHANGELOG and the commit log to find out if the bug was already fixed in the main branch.
  • I have included in the "Description" section below a traceback from any exceptions related to this bug.
  • I have included in the "Related issues or possible duplicates" section below all related issues and possible duplicate issues (If there are none, check this box anyway).
  • I have included in the "Environment" section below the name of the operating system and Python version that I was using when I discovered this bug.
  • I have included in the "Environment" section below the output of pip freeze.
  • I have included in the "Steps to reproduce" section below a minimally reproducible example.

Description

cached_path() function up to version 1.0.2 would involve a call to os.path.expanduser.
after changed into a Path, it may also require a call to Path.expanduser().

Python traceback:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/zxarukas/code/temp/cached_path/cached_path/_cached_path.py", line 186, in cached_path
    raise FileNotFoundError(f"file {url_or_filename} not found")
FileNotFoundError: file ~/.bash_profile not found

Related issues or possible duplicates

  • None

Environment

OS: macOS 10.15.7

Python version: 3.8.6

Output of pip freeze:

absl-py==1.0.0
adabelief-pytorch==0.2.1
allennlp==2.9.0
appnope==0.1.2
APScheduler==3.6.3
argon2-cffi==20.1.0
asttokens==2.0.5
attrs==21.2.0
backcall==0.2.0
backports.csv==1.0.7
backports.zoneinfo==0.2.1
base58==2.1.1
beautifulsoup4==4.9.3
black==22.1.0
bleach==4.0.0
blis==0.7.4
boto3==1.18.26
botocore==1.21.26
cached-path==1.1.0
cachetools==4.2.2
catalogue==2.0.6
certifi==2021.5.30
cffi==1.14.6
chardet==4.0.0
charset-normalizer==2.0.4
checklist==0.0.11
cheroot==8.5.2
CherryPy==18.6.1
click==7.1.2
colorama==0.4.4
configparser==5.0.2
cryptography==3.4.7
cymem==2.0.5
debugpy==1.4.1
decorator==5.0.9
defusedxml==0.7.1
dill==0.3.4
docker-pycreds==0.4.0
docutils==0.18
entrypoints==0.3
executing==0.8.2
fairscale==0.4.5
feedparser==6.0.8
filelock==3.4.2
future==0.18.2
gitdb==4.0.7
GitPython==3.1.20
google-api-core==2.0.0
google-auth==2.0.1
google-auth-oauthlib==0.4.6
google-cloud-core==2.0.0
google-cloud-storage==1.41.1
google-crc32c==1.1.2
google-resumable-media==2.0.0
googleapis-common-protos==1.53.0
grpcio==1.44.0
h5py==3.4.0
huggingface-hub==0.2.1
idna==3.2
importlib-metadata==4.8.1
iniconfig==1.1.1
ipdb==0.13.9
ipykernel==6.2.0
ipython==7.31.1
ipython-genutils==0.2.0
ipywidgets==7.6.3
iso-639==0.4.5
jaraco.classes==3.2.1
jaraco.collections==3.4.0
jaraco.functools==3.3.0
jaraco.text==3.5.1
jedi==0.18.0
Jinja2==3.0.1
jmespath==0.10.0
joblib==1.0.1
jsonnet==0.17.0
jsonschema==3.2.0
jupyter==1.0.0
jupyter-client==7.0.1
jupyter-console==6.4.0
jupyter-core==4.7.1
jupyterlab-pygments==0.1.2
jupyterlab-widgets==1.0.0
keyring==23.2.1
langcodes==3.3.0
lark==0.11.3
lmdb==1.2.1
lxml==4.6.3
Markdown==3.3.6
MarkupSafe==2.0.1
matplotlib-inline==0.1.2
mistune==0.8.4
more-itertools==8.8.0
munch==2.5.0
murmurhash==1.0.5
mypy-extensions==0.4.3
nbclient==0.5.4
nbconvert==6.1.0
nbformat==5.1.3
nest-asyncio==1.5.1
nltk==3.6.2
notebook==6.4.3
numpy==1.22.2
oauthlib==3.2.0
overrides==3.1.0
packaging==21.0
pandas==1.3.2
pandocfilters==1.4.3
parso==0.8.2
pathspec==0.9.0
pathtools==0.1.2
pathy==0.6.0
patternfork-nosql==3.6
pdfminer.six==20201018
pexpect==4.8.0
pickleshare==0.7.5
Pillow==8.3.1
pkginfo==1.7.1
platformdirs==2.4.1
pluggy==0.13.1
portend==2.7.1
preshed==3.0.5
prometheus-client==0.11.0
promise==2.3
prompt-toolkit==3.0.20
protobuf==3.17.3
psutil==5.8.0
ptyprocess==0.7.0
pure-eval==0.2.2
py==1.10.0
pyasn1==0.4.8
pyasn1-modules==0.2.8
pycparser==2.20
pydantic==1.8.2
Pygments==2.10.0
pyparsing==2.4.7
pyrsistent==0.18.0
pytest==6.2.4
python-dateutil==2.8.2
python-docx==0.8.11
python-telegram-bot==13.7
pytz==2021.1
PyYAML==5.4.1
pyzmq==22.2.1
qtconsole==5.1.1
QtPy==1.10.0
readme-renderer==30.0
regex==2021.8.21
requests==2.26.0
requests-oauthlib==1.3.1
requests-toolbelt==0.9.1
rfc3986==1.5.0
rsa==4.7.2
s3transfer==0.5.0
sacremoses==0.0.45
scikit-learn==0.24.2
scipy==1.7.3
Send2Trash==1.8.0
sentencepiece==0.1.96
sentry-sdk==1.3.1
sgmllib3k==1.0.0
shortuuid==1.0.1
six==1.16.0
smart-open==5.2.0
smmap==4.0.0
sortedcontainers==2.4.0
soupsieve==2.2.1
spacy==3.2.2
spacy-legacy==3.0.8
spacy-loggers==1.0.1
sqlparse==0.4.2
srsly==2.4.1
stack-data==0.1.4
subprocess32==3.5.4
tabulate==0.8.9
tempora==4.1.1
tensorboard==2.8.0
tensorboard-data-server==0.6.1
tensorboard-plugin-wit==1.8.1
tensorboardX==2.4
termcolor==1.1.0
terminado==0.11.1
testpath==0.5.0
thinc==8.0.13
threadpoolctl==2.2.0
tokenizers==0.10.3
toml==0.10.2
tomli==2.0.0
torch==1.9.0
torchvision==0.10.0
tornado==6.1
tqdm==4.62.1
traitlets==5.0.5
transformers==4.15.0
trialbot==0.3.7
twine==3.5.0
typer==0.3.2
typing-extensions==3.10.0.0
tzlocal==3.0
urllib3==1.26.6
wandb==0.11.2
wasabi==0.8.2
wcwidth==0.2.5
webencodings==0.5.1
Werkzeug==2.0.3
widgetsnbextension==3.5.1
zc.lockfile==2.0
zipp==3.6.0

Steps to reproduce

just clone the repo and run from the command line will raise the exception, which exits gently in v1.0.2.

Example source:

git clone https://github.com/allenai/cached_path.git && cd cached_path;
python -c 'from cached_path import cached_path; cached_path("~/.bash_profile")'

Thanks for the details bug report @zxteloiv! #78 should fix. I'll deploy a patch release as soon as that's merged.