Skip to content

Remove unused imports #13216

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

Draft
wants to merge 49 commits into
base: develop
Choose a base branch
from

Conversation

Akirathan
Copy link
Member

@Akirathan Akirathan commented Jun 3, 2025

Follow-up of #13017

Pull Request Description

Important Notes

Checklist

Please ensure that the following checklist has been satisfied before submitting the PR:

  • The documentation has been updated, if necessary.
  • Screenshots/screencasts have been attached, if there are any visual changes. For interactive or animated visual changes, a screencast is preferred.
  • All code follows the
    Scala,
    Java,
    TypeScript,
    and
    Rust
    style guides. In case you are using a language not listed above, follow the Rust style guide.
  • Unit tests have been written where possible.
  • If meaningful changes were made to logic or tests affecting Enso Cloud integration in the libraries,
    or the Snowflake database integration, a run of the Extra Tests has been scheduled.
    • If applicable, it is suggested to paste a link to a successful run of the Extra Tests.

@Akirathan Akirathan self-assigned this Jun 3, 2025
@Akirathan Akirathan added the CI: No changelog needed Do not require a changelog entry for this PR. label Jun 3, 2025
Copy link

github-actions bot commented Jun 3, 2025

✨ GUI Checks Results

Summary

  • 🧹 Prettier: ✅ Passed
  • 🧰 GUI Checks: ❌ Failed
  • 📚 Storybook: ❌ Failed

⚠️ Action Required: Please review the failed checks and fix them before merging.

See individual check results for more details.

@Akirathan
Copy link
Member Author

Akirathan commented Jun 10, 2025

What to do with extension method imports that are reported as unused?

Extension methods can be imported in various ways. Having module Extensions.enso, inside which there is just

Any.extension_method self = 42

it can be imported from other module via import project.Extensions or from project.Extensions import all or from project.Extensions import extension_method.

The "plain" import import project.Extensions is problematic, because it may get reported as unused. For example, in the following module:

import project.Extensions

foo =
    42.extension_method

the import will be reported as unused.

There is not much we can do about it at this moment. The algorithm for unused import reporting uses BindingsMap.Resolution metadata from IR nodes to detect which symbols are used. In this case, there is no such metadata.

The commit that adds back some imports that are used only for extension methods (and therefore were previously reported as unused) is at 4ea0982

Solution

Rule of a thumb will be: use from project.Data.Text.Extensions import all when importing extension methods. That way, the UnusedImport pass will ignore it. Moreover, from the syntax perspective, it is more clear than using pure import project.Data.Text.Extensions

@Akirathan Akirathan added the CI: Clean build required CI runners will be cleaned before and after this PR is built. label Jun 12, 2025
# Conflicts:
#	distribution/lib/Standard/Database/0.0.0-dev/src/DB_Column.enso
#	distribution/lib/Standard/Table/0.0.0-dev/src/In_Memory_Column.enso
#	distribution/lib/Standard/Visualization/0.0.0-dev/src/Table/Visualization.enso
@Akirathan
Copy link
Member Author

The unused import compiler pass is pretty slow. Making sure it is enabled only if --enable-static-analysis cmdline option is specified - 0be04ad.

@Akirathan
Copy link
Member Author

TODO [note to myself]: First integrate all the changes to *.enso files in a separate PR - once the Enso Lint CI job passes on this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI: Clean build required CI runners will be cleaned before and after this PR is built. CI: No changelog needed Do not require a changelog entry for this PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant