Nasdaq / data-link-python

A Python library for Nasdaq Data Link's RESTful API
MIT License
428 stars 70 forks source link

feat: Trim API-key file #9

Closed edvn0 closed 2 years ago

edvn0 commented 2 years ago

This commit fixes a bug which happened on my machine (MacOS Monterey 12.1) - when pasting the key from the webpage into the apikey-file in the default directory, the python API broke - complaining on both "\n" file endings and spaces.

Splitting on a space makes sense I believe, since the API-key are presumably never (reject this PR if so) space-inclusive.

couture-ql commented 2 years ago

Ah, yes, we could do more work to prune any whitespace when reading.

It would be preferable, in my opinion, to .strip() instead.

edvn0 commented 2 years ago

I agree, however, I did not know if the API-keys contained whitespaces in the content (I've seen keys like key="API "), therefore opting for my solution. Strip is absolutely more pythonic and general if that is not the case.

couture-ql commented 2 years ago

API Keys do not contain whitespace. What I suspect is happening is the copy/paste from the website's snippet is including extra characters and giving you grief. We'll try to see if that can be addressed separately in a future UI update of the website.

I've pushed out #11 with some test cases that should help solve the issue.

My solution is rather aggressive, especially when we anticipate users to only have a config file with one line -- we now try to work extra hard to split and return the first non-empty value.

couture-ql commented 2 years ago

Closing due to preferred #11

Thanks for bringing this to our attention. We'll be releasing a new version shortly.