-
Notifications
You must be signed in to change notification settings - Fork 252
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
drop isort and black from pyproject.toml #275
Conversation
Just seen that you opened an MR. Per #274 (comment) I don't know that I think this is a good idea; but since we have this MR it makes sense to continue any discussion here rather than there. |
It's desirable to run tools such as mypy and isort in the virtual environment of the project. This project's precommit configuration currently fails to do this. This MR is IMO a step in the wrong direction. https://github.com/pre-commit/mirrors-mypy suggests that the way to get the dependencies you want in place for the mypy precommit is by repeating them in precommit configuration
That duplication with pyproject.toml is clearly undesirable. I'd propose that pyproject.toml should be the source of truth for creating the environment in which development and testing happens, and pipelines should use that. (This seems to be slightly contentious in the precommit world, I found a couple of tetchy threads. I probably don't understand the issues.) I think the way to do that would be to put |
there are good reasons to remove these pre-commit dependencies from the On the other hand having pyproject.toml as the source of truth has some advantages
There's some tension between the two trade-offs. I agree with the sentiment of this PR though- having them duplicated in both places is problematic. |
We should keep it easy for contributors. Telling them to run I agree that this isn't ideal for
Any IDE that is able to run external commands, can run the linter via pre-commit as well, e.g. This PR is only about dropping isort and black from pyproject.toml. Maybe we could discuss the special case mypy on discord? Whatever is decided, it should then be applied to poetry and poetry-core. |
@dimbleby: I guess you've something like this in your mind? https://jaredkhan.com/blog/mypy-pre-commit Looks like this is something we should give a try for mypy. |
Yes, that's the sort of thing. I don't know how convenient this is though, you must need to do something to bootstrap the virtual environment eg install poetry and perhaps this is too heavyweight for a precommit hook. To be honest I'm a little sceptical of the whole pre-commit approach. My inclination would be to do all the linting in a regular github workflow, just like the testing. Personally I wouldn't miss the git hook at all - though it's entirely reasonable to think the opposite. (I don't think it's mypy that's the special case here. Most of the python linting tools expect to be in the project environment. If anything is the special case I'd suggest that it's black, which doesn't mind about the environment Edit: apparently I am not keeping up with the isort world. It used to have lots of magic to decide sort order by detecting what was going on in the environment, but apparently as of its 5.0.0 release does not do this.) |
Hiya, thought I would suggest a middle-of-the-road approach here, which is that you could put the linting dependencies into an extra, and then people can pick whether they want them or not. It's not quite as easy as installing by default, but it keeps the rest of the benefits. |
The motivation is to avoid duplicating the list of dependencies between pyproject.toml and precommit config. I don't see how making them extras helps? |
Ah, I see, they are already getting installed by pre-commit, not poetry. |
3975e67
to
9d50898
Compare
Kudos, SonarCloud Quality Gate passed! |
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.
Fwiw, I agree with @finswimmer the goal is to make it easier to work with the code base and remove surprises when submitting pull requests. Additionally, this removes the unnecesary duplication for now. For black
and isort
, these can be fully managed by pre-commit
and does not require to be in the project environment.
With that in mind, I say we merge this as this and deal with the mypy
case as and when it pops up. This change is in line with what we do for poetry right now anyway.
Drop
isort
andblack
frompyproject.toml
, because these linter are running viapre-commit
.