-
Notifications
You must be signed in to change notification settings - Fork 193
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
Added Decimal to numeric types and allow petl.compat.numeric_types to be customized #568
base: master
Are you sure you want to change the base?
Conversation
…types. The current code does not right-align numeric types when converting to text. numeric_types is defined in petl.compat. The following customization (via monkey-patching, yes, I know) does not work, however: import petl.compat petl.compat.numeric_types = petl.compat.numeric_types + (Decimal,) because in petl/util/vis.py it is accessed like this: from petl.compat import numeric_types, text_type and this module gets loaded as a side-effect of importing petl. Changing it to this - everywhere it is used - would fix the issue: from petl import compat ... isinstance(..., compat.numeric_types) ...
I think it would be nice to have this feature in I'm wondering if you already have some thoughts on what would be a proper API for unlocking this feature instead of |
Maybe providing a function to call instead, e.g., add_numeric_types() but then the whole thing could devolve into multiple functions for each of the customizable lists, mirroring a bunch of stuff for basically not every much protection. Personally I think just make those mutable is simpler, but perhaps with some instructions around it. It's a rarity, and in the patch I'm adding Decimal by default anyway. I'd leave it as is. Sometimes no API is the better API, and I think this is one of those cases. |
Yes, I agree. But I'm wondering if it's worth getting rid of compat like in #478 instead of bothering with this python2 compatibility hack. Maybe merging the |
I think that's beyond my level of involvement with the library so far, it's a decision for the maintainers. My personal view, without the full context around version support expectations, is that yes, Python2 at this stage could be dropped. I mean it's been a very long while now. In any case, a list of numeric types would be required. So in my opinion it's an orthogonal issue. |
As stated in the @alimanfoo petl's author roadmap and in the comments of #563, I think that the move is uncontroversial at this point. The remaining issue is the lack of manpower for evolving the changes in #563, #336, a few other issues, and fix the packaging to pip, Conda, and readthedocs.org. |
This PR has two objectives:
The main purpose is for Decimal numbers to align-right in the vis/look() functions.
Checklist
Anything else you need just let me know.