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

Issue with linter for including PATH insert statements before other module imports #24

Closed
sumanbhagavathula opened this issue Jun 11, 2019 · 1 comment
Assignees

Comments

@sumanbhagavathula
Copy link
Collaborator

The project has several modules in the MVC folder structures. During development and unit testing it was found that the import statement for the modules from different directories does not work unless we include statement to insert the path to the modules. However, the caveat is that these insert statement and the corresponding import sys statement need to be present before the statement to import the project modules from other directories. This violates the styling principles of having import statements at the beginning of the file and having import statements in alphabetical order. This is caught by linter as well, and we had to suppress it by applying a linter hint to ignore the relevant error message for this specific case.

An example below, taken from LIME_Education_Ex.py. As you can see from below, we had to import sys and include statements to insert the MVC folder paths into PATH environment variable with the sys.path.insert command. And the actual required import statement(s) is after the "extra" import and insert statements.

import sys
sys.path.insert(0, '../LIMEaid/LIMEaid/controller')
sys.path.insert(0, '../LIMEaid/LIMEaid/model')
sys.path.insert(0, '../LIMEaid/LIMEaid/view')
import fit_sklearn_models as fsm

The workaround is in travis.yml file on line 37, NOTE the ignore switch and the argument value.
flake8 LIMEaid --ignore=E402

@sumanbhagavathula sumanbhagavathula self-assigned this Jun 11, 2019
@sumanbhagavathula sumanbhagavathula changed the title Issue with importing project modules from different directory paths Issue with importing project modules from different directory paths (using cloned repo) Jun 11, 2019
@sumanbhagavathula
Copy link
Collaborator Author

Closed with workaround.

@sumanbhagavathula sumanbhagavathula changed the title Issue with importing project modules from different directory paths (using cloned repo) Issue with linter for including PATH insert statements before other module imports Jun 11, 2019
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

No branches or pull requests

1 participant