Skip to content
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

flake8 config error #540

Closed
ivirshup opened this issue Apr 7, 2021 · 9 comments
Closed

flake8 config error #540

ivirshup opened this issue Apr 7, 2021 · 9 comments
Assignees
Labels

Comments

@ivirshup
Copy link
Member

ivirshup commented Apr 7, 2021

There is a space in front of the per-file-ignore entry in the flake8 config (added in scverse/scanpy#1689). This is the same in scanpy, as the config here was just copied from there. This causes a parse failure which leads to the the per-file-ignores becoming global instead. To demonstrate:

Parse failure

From the root of the repo

>>> from flake8.api.legacy import get_style_guide
>>> get_style_guide().options.ignore
['#',
 'module',
 'imported',
 'but',
 'unused',
 '->',
 'required',
 'for',
 'Scanpys',
 'API',
 'F401',
 'W503',
 'W504',
 'E501',
 'E203',
 'E231',
 'E402',
 'E126',
 'E262',
 'E266',
 'E731',
 'E741',
 'per-file-ignores',
 '=',
 'tests/test*.py:',
 'F811',
 'anndata/compat/_overloaded_dict.py:',
 'F821',
 'anndata/tests/test_readwrite.py:',
 'E721']

Fixing the parse error reveals a number of flake8 errors which were accidentally being ignored. I came across this while adding back F401, since it should only be ignored for files which define a namespace.

It is kind of ironic that a tool for enforcement of code style is permissive to a fault about config parsing.

(ping @Zethson)

@flying-sheep
Copy link
Member

@asottile can you help making such bugs impossible in the future? Implementing PyCQA/flake8#234 might be an easy way to do it.

@Zethson Zethson self-assigned this Apr 7, 2021
@Zethson
Copy link
Member

Zethson commented Apr 7, 2021

Nice catch @ivirshup. Sorry for this. I'll fix the config file.

@ivirshup
Copy link
Member Author

ivirshup commented Apr 7, 2021

@flying-sheep has the first issue here been resolved PyCQA/flake8#234 (comment)? If not, I don't think this is going to happen anytime soon. Even after this is implemented for flake8, other tools which read the flake8 config would need to recognize the pyproject.toml entries (e.g. vscode, autopep8, etc.).

@Zethson no worries, all three of us managed to miss this. I'd really expect this sort of thing to cause a parse error.

Zethson added a commit that referenced this issue Apr 7, 2021
Signed-off-by: zethson <lukas.heumos@posteo.net>
@asottile
Copy link

asottile commented Apr 7, 2021

really, this was all just a ploy to @ mention me about the pyproject.toml issue? welcome to my blocklist

@flying-sheep
Copy link
Member

@ivirshup yes it has been. pyproject.toml needs to have the build-system table to change pip’s behavior.

@asottile No, but I’m sorry I touched an apparently very emotional issue for you. I mentioned it because it’s the easy way. Manual validation would be another option that’s harder to implement. But if you really blocked me you’re not going to read this anyway …

@asottile
Copy link

asottile commented Apr 7, 2021

yes it has been. pyproject.toml needs to have the build-system table to change pip’s behavior.

it has not, the presence of the file alone still changes pip's behaviour in 21.0.1

@flying-sheep
Copy link
Member

flying-sheep commented Apr 8, 2021

Oh interesting! I thought this was about when the presence of pyproject.toml made pip assume it’s not a legacy build (and therefore made it not use setup.py). They fixed that one long ago: Unless the build-system table is there, pip just assumes a setup.py build.

/edit: Ah found it. pypa/pip#8437 (comment)

So basically the’re saying that the only code path that changes is very much deprecated. Therefore, if I understand correctly, the behavior that happens when pyproject.toml exists is the one that should be used, and projects should switch to a standard way of building instead of sticking with “just setup.py”. Did I get this right?

Direct installs

What does have an impact here is the even older ("legacy legacy", if you like 🙂) behaviour of installing directly with setup.py install. We've been trying to kill that behaviour for years now - it bypasses all modern standards and behaviour, and uses unsafe and generally deprecated mechanisms. Removal of that behaviour generally gets discussed under the term "install via wheel".

The thing is, if you are doing a direct install, build isolation is irrelevant, because we don't do a build! So anything that uses the direct-install code path doesn't use build isolation. This is (I believe) the code path that is being taken by projects that are complaining that adding pyproject.toml imposes build isolation on them.

Important part:

But what I am saying is that every part of this behaviour is in code that we've been trying to deprecate and remove for at least 3 years, and probably longer. We're retaining the old behaviour because we don't have a good way of warning users that change is coming - so we have to make the transition extremely long. But "fixing" breakages where users have encountered the change and want some of the benefits but don't want to complete the work to switch, is deliberately extending the transition period, and does nothing to help us achieve the ultimate goal of removing all of that old code.

So I guess when they finally delete that code and only the new behavior exists, there will be no differential behavior anymore.

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity.
Please add a comment if you want to keep the issue open. Thank you for your contributions!

@github-actions github-actions bot added the stale label Jun 27, 2023
@flying-sheep
Copy link
Member

flying-sheep commented Jun 27, 2023

Fixed in #863 and then superseded by #891.

Anyone interested in isolated builds in pip can go here: pypa/pip#9175

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants