Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle two warnings that pollute the output of sssom-py CLI #561
Handle two warnings that pollute the output of sssom-py CLI #561
Changes from 2 commits
68917a0
21019c7
a13e224
c269ece
d0051bc
e0cbe73
634b1d9
d2b244e
fbee866
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rather put that somewhere when the library is initialized, so that we can be sure the option is enabled everywhere at all times and not only when the code path goes through this particular function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added it to sssom/init.py, not sure this is the right thing to do (can this effect other libraries that might not want that option to be set for some reason?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would personally be fine having it in
sssom/init.py
. This is forcing the behaviour to apply globally, which I believe is a good thing.That being said, it is true that this could have cascading effects for people who are using
sssom
as a library rather than as a command-line tool (people who importsssom
in their own Python projects, rather than callingsssom-py
from the command line), if they also happen to be usingpandas
in the rest of their code (no problem if their only use ofpandas
is throughsssom
).If you’re not comfortable forcing the “no downcasting” behaviour to all potential users of the
sssom
Python module¹, I can think of two options:(A) Setting the option somewhere at the beginning of the
main
function insssom/cli.py
. This means the option will be enabled globally in all ofsssom
when it is used as a CLI tool, but not when it is used as an imported module in another Python project.It will then be up to the people who imports
sssom
to decide whether they themselves want to enable the “no downcasting” behaviour, by setting (or not) the option.(B) Enabling the option within
sssom
, but only where we need it and only for the duration we need it. That is, we enable it before callingreplace
here, and disable it afterwards.A context manager would come in handy here:
It could then be used whenever we have to perform an operation and need to locally make sure the option (if it is available and if it is not already set) is enabled:
This is equivalent to:
except that it is more “pythonic” and it deals gracefully with the possible absence of that option or the possibility that the option has already been enabled elsewhere.
¹ But it should be noted that this behaviour will be forced upon them sooner or later anyway, since it will be the only behaviour available in Pandas 3.0… Better for those people to start dealing with it now.