-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
add slotscheck to CI #7670
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
add slotscheck to CI #7670
Conversation
Is this ready for additional testing in gerrit? |
@zzzeek yes. I'm wondering though if pre-commit is the best place for slotscheck. Is there a specific reason some checks are in tox/pre-commit/github-actions? |
Things in tox are tested in Jenkins CI. Things in github actions are tested there. things in pre-commit are run every time we commit. so in pre-commit, black and zimports are there since they actually change the code. so those only belong in pre-commit. but we also have flake8 there, because it catches so many quick things very fast, it just helps filter out quick issues before we push up to gerrit, which would then kick of jenkins builds which are more time / resource consuming. my impression of slotscheck is that it can work as a quick flake8- sort of thing. but yes, overall it should likely be part of tox and github actions as well. it seems right now to not fit cleanly into any of our particular targets, but it's more convenient for us if we make it part of the existing targets - the pep8 target is right now where we have generic "code quality" checks where we not only call upon flake8 (which checks way more than pep8) we also have "black check" in there. id have to try the tool out a little bit to get a feel for it but yes I think it would first be part of the "pep8" target at the moment, how does that seem? |
@zzzeek thanks for the comprehensive answer! I initially added it to pre-commit following the suggestion in #7589 (comment), but I'd say There was a similar discussion in aio-libs/aiohttp#6547 (comment), where the conclusion was to add |
that's fine let's do it that way then! |
|
the rename is fine but you would need to add another target pep8 that imports the "lint" target, so that our CI which is hardcoded to "pep8" for all projects continues to work, until we can make this name change for all projects (alembic, dogpile, mako) |
I've re-added |
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.
OK, this is sqla-tester setting up my work on behalf of zzzeek to try to get revision 3e77fe5 of this pull request into gerrit so we can run tests and reviews and stuff
lets try it out |
New Gerrit review created for change 3e77fe5: https://gerrit.sqlalchemy.org/c/sqlalchemy/sqlalchemy/+/3576 |
mike bayer (zzzeek) wrote: just gave it a spin removing a "slots()", to see how straightforward it is. output is very clear: ERROR: 'sqlalchemy.sql.roles:DMLTableRole' has slots but superclass does not. very nice! View this in Gerrit at https://gerrit.sqlalchemy.org/c/sqlalchemy/sqlalchemy/+/3576 |
mike bayer (zzzeek) wrote: I've searched the entire codebase of slotscheck to see where it's using mypy, and I see nothing; no imports of anything in mypy, no command line running of mypy. Why is mypy a dependency? https://github.com/ariebovenberg/slotscheck/search?q=mypy View this in Gerrit at https://gerrit.sqlalchemy.org/c/sqlalchemy/sqlalchemy/+/3576 |
mike bayer (zzzeek) wrote: oh that's to import our mypy plugin. OK. let me alter that to indicate it's using the sqlalchemy[mypy] target. I found some other slots checks that were missing because they are in our non-C ext fallback code, so I am fixing that also. View this in Gerrit at https://gerrit.sqlalchemy.org/c/sqlalchemy/sqlalchemy/+/3576 |
Federico Caselli (CaselIT) wrote: Looks ok to me View this in Gerrit at https://gerrit.sqlalchemy.org/c/sqlalchemy/sqlalchemy/+/3576 |
@zzzeek indeed Regarding C-extensions, the situation here is interesting! It looks like it may be needed to have two slotscheck checks (one if typing.TYPE_CHECKING or not HAS_CYEXTENSION:
from ._py_collections import ImmutableContainer
# ...
else:
from sqlalchemy.cyextension.immutabledict import ImmutableContainer
# ... where both |
oh i wasnt even sure if cython was an option here (@CaselIT does slots apply to cython even? I thought we have to name all the variables anyway?) . OK, well, if cython builds, the py versions of the objects are still available, and slotscheck is probably checking them. in this case it likely missed these two because there were no inheriting objects from them at runtime. |
that's on |
mike bayer (zzzeek) wrote: oh i know how to fix this View this in Gerrit at https://gerrit.sqlalchemy.org/c/sqlalchemy/sqlalchemy/+/3576 |
But of course, it cannot trace multiple code branches at once ( This 'double' check is the only way to find both |
yup, all makes sense, thanks |
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.
mike bayer (zzzeek) wrote:
ah, we only run lint on ubuntu, we're good
View this in Gerrit at https://gerrit.sqlalchemy.org/c/sqlalchemy/sqlalchemy/+/3576
# Kept for backwards compatibility until rename is completed elsewhere. | ||
[testenv:pep8] | ||
basepython = {[testenv:lint]basepython} | ||
deps = {[testenv:lint]deps} |
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.
mike bayer (zzzeek) wrote:
the lint action doesn't, problem solved
View this in Gerrit at https://gerrit.sqlalchemy.org/c/sqlalchemy/sqlalchemy/+/3576
Gerrit review https://gerrit.sqlalchemy.org/c/sqlalchemy/sqlalchemy/+/3576 has been merged. Congratulations! :) |
As discussed in sqlalchemy#7589, `slotscheck` can prevent slots-related mistakes from creeping back in. Plan for now is to have slotscheck part of the "lint" tests (renamed from pep8) that will run for CI and github actions. To support slotscheck's runtime nature, slotscheck is run twice, first with cython exts enabled and then with them disabled via new environment variable. Also added sqlalchemy[mypy] dependency to support slots checking the mypy plugin. Found and fixed one more `__slots__` issue by disabling C exts. Closes: sqlalchemy#7670 Pull-request: sqlalchemy#7670 Pull-request-sha: 3e77fe5 Change-Id: I90cdd284cdcee316a38856ba94d72ffc98947c5a
Description
As discussed in #7589,
slotscheck
can prevent slots-related mistakes from creeping back in.Note that because slotscheck imports files,
additional_dependencies
was needed in the pre-commit config. The versions of these dependencies are not kept in sync withsqlalchemy
requirements. If this is not OK, there are alternative setups or the check could be moved totox
.Checklist
must include a complete example of the issue. one line code fixes without an
issue and demonstration will not be accepted.
Fixes: #<issue number>
in the commit messageHave a nice day!