haxsaw/hikaru

Black maybe better be a dev dependency

wtayyeb opened this issue · 5 comments

get_python_source is the only place used black.format_file_contents, black.FileMode but this function is not for real world usage. it is better to move it to another file and black to dev requirements, so if any user need to use it in development envionment, he could install in seperately

I'm not sure what you mean by 'dev requirements'; are you saying as part of the requirements for maintainers of Hikaru? Because users of Hikaru are doing development as well, and one of the use cases is to use Hikaru to transform a big swath of YAML into Python. I'm not keen on requiring such users to have to install all the maintainers requirements to support this use case. It sounds like you mostly object to black.FileMode (or what should probably be just Mode now), not the presence of black itself. I'm not sure what the problem with using Mode is, but if you can suggest an alternative way to perform in-memory formatting with black that doesn't involve Mode I'd consider adopting that approach.

So I had a chat with the black devs and have shifted my use of their functions to what they recommended, as they feel these will be a close approximation to what the public interface will be. In the interim, I've pinned the requirement for the version of black that Hikaru uses (not optimal, I know), and will track black releases for when they release their official public API. Hopefully that'll address your concerns.

thank you for your response,
I mean developing own code, not hikaru code. For example someone have a code base (using hikaru as a library in it), and for debugging he may need get_python_source. he never use this function when deploying his project.

about the placement of dependency, it could moved into setup.py extra_required section, (albeit it could placed in in a requirements-dev.txt file but it will not installed via pip)

setup(
    ...
    extras_require={
        'dev': [
            'black',
        ],
    },

so whoever needs hikaru development dependencies he could installe them by pip install hikaru[dev].
the dev term could be anything. and if it is confusing, just change it to what is better.

In general, I'm not a fan of the user experience where an additional install step is required to use all the features of Hikaru. It's non-obvious, it requires reading doc where one would otherwise not be required to, and it only defers the issue that you are concerned with. I take the point that you are making, and certainly anyone else using black might well be troubled by Hikaru pinning it's requirements, but for the time being I'd be happier to just create a point release to accommodate a new release of black rather than separate out support for black (but not autopep8) even though we're probably close to the actual interface. I'm sorry, I'm just not seeing a compelling case for this, but will be willing to reconsider if circumstances change.

ok, thanks