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

init: Fix F401 Linter Warnings by Replacing Wildcard Imports with Explicit Imports in __init__.py #4647

Merged
merged 18 commits into from
Nov 16, 2024

Conversation

arohanajit
Copy link
Contributor

Addresses multiple F401 linter warnings in the __init__.py file by replacing wildcard imports with explicit imports and defining the __all__ variable to specify the public API of the module. Replaced Wildcard Imports: Removed from .data import * and explicitly imported the necessary functions and classes. Also updated .flake8 since no F403 warnings were found

@github-actions github-actions bot added Python Related code is in Python libraries labels Nov 4, 2024
@arohanajit arohanajit changed the title app: Fix F401 Linter Warnings by Replacing Wildcard Imports with Explicit Imports in __init__.py init: Fix F401 Linter Warnings by Replacing Wildcard Imports with Explicit Imports in __init__.py Nov 4, 2024
@echoix

This comment has been minimized.

@petrasovaa petrasovaa added this to the 8.5.0 milestone Nov 5, 2024
Copy link
Contributor

@petrasovaa petrasovaa left a comment

Choose a reason for hiding this comment

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

You have several duplications in all...

Copy link
Contributor

@petrasovaa petrasovaa left a comment

Choose a reason for hiding this comment

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

You need to run isort and the CI fails because there is missing Popen class from core.py

Copy link
Contributor

@petrasovaa petrasovaa left a comment

Choose a reason for hiding this comment

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

The CI fails:

  File "scripts/t.vect.import", line 113, in main
    tgis.import_stds(
  File "etc/python/grass/temporal/stds_import.py", line 250, in import_stds
    old_state = gs.raise_on_error
AttributeError: module 'grass.script' has no attribute 'raise_on_error'. Did you mean: 'get_raise_on_error'?

because there is missing raise_on_error from core.py. But I would say in this case it should use the getter anyway:

old_state = gs.get_raise_on_error()

So the variable probably should not be exposed.

@arohanajit
Copy link
Contributor Author

The CI fails:

  File "scripts/t.vect.import", line 113, in main
    tgis.import_stds(
  File "etc/python/grass/temporal/stds_import.py", line 250, in import_stds
    old_state = gs.raise_on_error
AttributeError: module 'grass.script' has no attribute 'raise_on_error'. Did you mean: 'get_raise_on_error'?

because there is missing raise_on_error from core.py. But I would say in this case it should use the getter anyway:

old_state = gs.get_raise_on_error()

So the variable probably should not be exposed.

So in this case CI will probably always fail unless we expose 'raise_on_error()` which we shouldn't. Is there another way to manage this?

@petrasovaa
Copy link
Contributor

The CI fails:

  File "scripts/t.vect.import", line 113, in main
    tgis.import_stds(
  File "etc/python/grass/temporal/stds_import.py", line 250, in import_stds
    old_state = gs.raise_on_error
AttributeError: module 'grass.script' has no attribute 'raise_on_error'. Did you mean: 'get_raise_on_error'?

because there is missing raise_on_error from core.py. But I would say in this case it should use the getter anyway:

old_state = gs.get_raise_on_error()

So the variable probably should not be exposed.

So in this case CI will probably always fail unless we expose 'raise_on_error()` which we shouldn't. Is there another way to manage this?

I was suggesting to do the change in stds_import.py

petrasovaa
petrasovaa previously approved these changes Nov 15, 2024
@echoix echoix self-assigned this Nov 16, 2024
@echoix
Copy link
Member

echoix commented Nov 16, 2024

The .flake8 changes mentioned in the PR description were lost in one of the commits. I tried cleaning it back locally, iterating by using pre-commit run -a flake8 between each change. So the init.py exclusions can be limited to python/grass/temporal.

@echoix echoix enabled auto-merge (squash) November 16, 2024 21:14
@echoix echoix merged commit 602118a into OSGeo:main Nov 16, 2024
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libraries Python Related code is in Python
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants