Configure Codacy to stop flagging valid "assert" statements
See original GitHub issueI’m submitting a …
- bug report
- feature request
Current behavior: Put a valid assert statement in Python code and Codacy will flag it:
- Use of assert detected. The enclosed code will be removed when compiling to optimized byte code. Pytest recommends the use of asset statements. The fact that the code will be removed is actually a feature, not an issue. We want to encourage the addition of new pytests.
Expected behavior:
- Codacy does not complain about valid Python.
Steps to fix: https://support.codacy.com/hc/en-us/articles/207279979-Issues#2-remove-pattern
NOTES:
On Mon, Oct 30, 2017 at 12:52 PM, "Ruxandra Barbu" <ruxandra.barbu@codacy.intercom-mail.com>
wrote:
Hi, thank you for contacting us.
Flagging the Python assert statements is a function of the Bandit linter itself.
You can ignore this issue in Codacy so it won´t affect the project. Please click here for
more details on how to ignore an issue/remove a pattern.
Please let me know if you have any other questions.
On Mon, Oct 30, 2017 at 01:55 AM, "cclauss" wrote:
Why does Codacy flag the Python assert statements that pytest recommends? I know about the
optimization that eliminates the asserts commands from production code but 1) no one ever
does that and 2) if I did it, I would consider it a feature not a problem. Anyway, I how do
I configure Codacy to stop flagging the asserts that Pytest recommends?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:9
- Comments:9 (6 by maintainers)
Top Results From Across the Web
Configuring code patterns - Codacy Quality docs
Configure the static analysis tools and code patterns that Codacy uses to ... To solve flagged valid Python "assert" statements, create a bandit.yml...
Read more >Configuring code patterns - Codacy docs
Configure the static analysis tools and code patterns that Codacy uses to ... To solve flagged valid Python "assert" statements, create a ...
Read more >Configuring code patterns - Codacy docs
Enable or disable the code patterns using the checkbox for each pattern. ... To solve flagged valid Python "assert" statements, create a ...
Read more >Code patterns - Codacy docs
However, you can create a coding standard adapted to your scenario by ... To solve flagged valid Python "assert" statements, create a ...
Read more >Codacy configuration file
To disable a tool you must use the Code patterns page instead. ... Add your settings to the configuration file based on the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It seems to me that the primary issue here is distinguishing between tests/testing code and project/production code. I don’t want to turn off the checking for asserts in my project code, but I do want the asserts used (sensibly) in my tests to pass checks for asserts silently.
Seems to me a solution would be to have a separate category for testing code, or code that pytest would run as tests, so I can turn on/off the “Assert used” pattern separately for testing/main project code.
@manoadamro Well unless you’re working on assessments or worksheets maybe (eg
test_templates
,test_solutions
), but once you run into this issue you’d think you’d change the filenames, or have all your tests under test_suite, You can then do:In your .codacy.yml file.