Skip to content

MAINT: enforce --ban-relative-imports in cython-lint - #32489

Merged
lesteve merged 5 commits into
scikit-learn:mainfrom
MarcoGorelli:ban-relative
Oct 13, 2025
Merged

lesteve merged 5 commits into
scikit-learn:mainfrom
MarcoGorelli:ban-relative

Conversation

@MarcoGorelli

Copy link
Copy Markdown
Contributor

#32315

I'd suggest enforcing the --ban-relative-imports option, else you'll be periodically re-fixing #32315 😄

Reference Issues/PRs

What does this implement/fix? Explain your changes.

Any other comments?

@github-actions

github-actions Bot commented Oct 13, 2025 •

Copy link
Copy Markdown

✔️ Linting Passed

All linting checks passed. Your pull request is in excellent shape! ☀️

Generated for commit: 62f2c1d. Link to the linter CI: here

@lesteve

lesteve commented Oct 13, 2025

Copy link
Copy Markdown
Member

Nice, thanks for the PR! I had it of the back of my head to do it one day or create an issue about it, but you beat me to it 🙏!

@lesteve

lesteve commented Oct 13, 2025

Copy link
Copy Markdown
Member

I pushed a commit to add --ban-relative-imports and another with an relative imports to test it.

This reverts commit bf101eb.
@lesteve

lesteve commented Oct 13, 2025

Copy link
Copy Markdown
Member

the check did fail with a relative import, see build log

### Running cython-lint ###

/home/runner/work/scikit-learn/scikit-learn/sklearn/manifold/_barnes_hut_tsne.pyx:16:0: Found relative import
Problems detected by cython-lint, please fix them

@lesteve lesteve left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks! I enabled auto-merge.

@lesteve
lesteve enabled auto-merge (squash) October 13, 2025 11:52
@lesteve
lesteve merged commit fdeeda1 into scikit-learn:main Oct 13, 2025
@lesteve

lesteve commented Oct 14, 2025

Copy link
Copy Markdown
Member

Side-comment for our future selves just in case: we have some .pyx.tp and .pxd.tp files where the cython files get generated. cython-lint is not going to check this for now. We could likely do something about it, but let's say it's YAGNI for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants