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

Add --allow-reexport-from-package option #8124

Merged
merged 4 commits into from
Jan 28, 2023

Conversation

cdce8p
Copy link
Member

@cdce8p cdce8p commented Jan 27, 2023

Description

Add option to reduce amount of false-positives for useless-import-alias when choosing to use explicit reexports.

Test might be a bit difficult as the result depends on the filename (if it's __init__.py). Not sure it's worth it.

Closes #6006

@codecov
Copy link

codecov bot commented Jan 27, 2023

Codecov Report

Merging #8124 (3925e73) into main (eb95061) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #8124   +/-   ##
=======================================
  Coverage   95.53%   95.53%           
=======================================
  Files         177      177           
  Lines       18600    18604    +4     
=======================================
+ Hits        17769    17773    +4     
  Misses        831      831           
Impacted Files Coverage Δ
pylint/checkers/imports.py 94.28% <100.00%> (+0.05%) ⬆️

@github-actions

This comment has been minimized.

Copy link
Member

@Pierre-Sassoulas Pierre-Sassoulas left a comment

Choose a reason for hiding this comment

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

Should we add a functional tests for this ? (We might need to unfilter __init.py).

I think the option make sense, the reason we did not do it at first is the time to implement / value ratio imo. Now that the work is done there's no reason not to do it.

if len(splitted_packages) == 1 and (
self._allow_reexport_package is False
or self._current_module_package is False
):
self.add_message("useless-import-alias", node=node)
Copy link
Member

Choose a reason for hiding this comment

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

Let's add the high confidence while we're at it.

@cdce8p
Copy link
Member Author

cdce8p commented Jan 28, 2023

Should we include it in 2.16?

@Pierre-Sassoulas Pierre-Sassoulas added this to the 2.16.0 milestone Jan 28, 2023
@Pierre-Sassoulas
Copy link
Member

Let's add to 2.16.0, we did a beta release not a blood contract swearing to feature freeze :D

@github-actions
Copy link
Contributor

🤖 According to the primer, this change has no effect on the checked open source code. 🤖🎉

This comment was generated for commit 3925e73

Copy link
Member

@Pierre-Sassoulas Pierre-Sassoulas left a comment

Choose a reason for hiding this comment

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

Nice !

@Pierre-Sassoulas Pierre-Sassoulas merged commit acb28d8 into pylint-dev:main Jan 28, 2023
@github-actions
Copy link
Contributor

The backport to maintenance/2.16.x failed:

The process '/usr/bin/git' failed with exit code 128

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-maintenance/2.16.x maintenance/2.16.x
# Navigate to the new working tree
cd .worktrees/backport-maintenance/2.16.x
# Create a new branch
git switch --create backport-8124-to-maintenance/2.16.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 acb28d8fcefb06179d9e6528ba14dd099e12ecfa
# Push it to GitHub
git push --set-upstream origin backport-8124-to-maintenance/2.16.x
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-maintenance/2.16.x

Then, create a pull request where the base branch is maintenance/2.16.x and the compare/head branch is backport-8124-to-maintenance/2.16.x.

@Pierre-Sassoulas Pierre-Sassoulas added Enhancement ✨ Improvement to a component and removed backport maintenance/2.16.x labels Jan 28, 2023
@Pierre-Sassoulas
Copy link
Member

No need to backport we're going to release 2.16.0 soon.

@cdce8p cdce8p deleted the reexport-package branch January 28, 2023 17:53
@cdce8p
Copy link
Member Author

cdce8p commented Jan 28, 2023

No need to backport we're going to release 2.16.0 soon.

👍🏻 Thought we had a maintenance branch for 2.16.x already.

@Pierre-Sassoulas
Copy link
Member

That's my bad I created the label way too early.

@cdce8p
Copy link
Member Author

cdce8p commented Jan 28, 2023

That's my bad I created the label way too early.

Depends. If the goal was a feature lock and only allow bugfixes, it would have been the right approach.

@Pierre-Sassoulas
Copy link
Member

We could do that if we introduce RC versions but tbh i think we juste need to release at this point

@cdce8p
Copy link
Member Author

cdce8p commented Jan 28, 2023

We could do that if we introduce RC versions but tbh i think we juste need to release at this point

👍🏻 Works for me! Just didn't know what you had in mind 😄

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

Successfully merging this pull request may close these issues.

false positive 'useless-import-alias' error for mypy-compatible explicit re-exports
2 participants