-
Notifications
You must be signed in to change notification settings - Fork 63
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
Don't throw e9999 for local imports #959
Conversation
Pull Request Test Coverage Report for Build 7234281424
💛 - Coveralls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @ChristopherLi05! Thanks for making this PR, and sorry for the veyr long delay in considering it.
Ultimately, the current behaviour of PythonTA is the preferred default. However, I would support adding a new boolean configuration option, allow-local-imports
, which provides users the option of allowing local imports. If you're interested in pursuing this, you can take a look at the other custom configuration options PythonTA supports; see, for example, #973.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks very much, @ChristopherLi05!
Motivation and Context
Addresses #945
Your Changes
Description:
I added the
get_local_files
method topython_ta/checkers/forbidden_import_checker.py#ForbiddenImportChecker
which gets all of the python files in the same directory as the file that the linter is currently checking. I then modifiedvisit_import
,visit_importfrom
, andvisit_call
to use this function so the checker won't throw an error when importing local files.I updated
examples/custom_checkers/e9999_forbidden_import.py
to add the lineimport e9999_forbidden_import_local # No error
.I created
examples/custom_checkers/e9999_forbidden_import_local.py
to demonstrate local file importing.Type of change (select all that apply):
The checker will no longer throw an e9999 error when importing a local file.
Testing
I ran
python -m pytest tests
to make sure I didn't mess the preexisting tests up.I then ran the following code to make sure that python_ta wouldn't throw an e9999 error on line 4.
Questions and Comments (if applicable)
Where is the test function/file for the
forbidden_import_checker
?Checklist