-
Notifications
You must be signed in to change notification settings - Fork 3
Flake8 showcase #5
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[flake8] | ||
max-line-length = 88 | ||
extend-ignore = E203, W503 | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,16 @@ | ||||||||||||||||||||||
import os, sys # F401: sys imported but unused | ||||||||||||||||||||||
|
||||||||||||||||||||||
def my_function( x, y ): | ||||||||||||||||||||||
print( "Result:",x+y ) # E201, E202, E231, E221 | ||||||||||||||||||||||
Comment on lines
+3
to
+4
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Fix function signature spacing and print statement formatting. The function contains multiple spacing violations that flake8 catches. -def my_function( x, y ):
- print( "Result:",x+y ) # E201, E202, E231, E221
+def my_function(x, y):
+ print("Result:", x + y) 📝 Committable suggestion
Suggested change
🧰 Tools🪛 Flake8 (7.2.0)[error] 4-4: indentation is not a multiple of 4 (E111) 🤖 Prompt for AI Agents
|
||||||||||||||||||||||
|
||||||||||||||||||||||
class myclass: # N801: class name should use CapWords convention | ||||||||||||||||||||||
def __init__(self): | ||||||||||||||||||||||
self.value =42 # E225: missing whitespace around operator | ||||||||||||||||||||||
Comment on lines
+6
to
+8
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Apply Python naming conventions and fix indentation. The class violates PEP 8 naming conventions and has inconsistent indentation. -class myclass: # N801: class name should use CapWords convention
- def __init__(self):
- self.value =42 # E225: missing whitespace around operator
+class MyClass:
+ def __init__(self):
+ self.value = 42 📝 Committable suggestion
Suggested change
🧰 Tools🪛 Flake8 (7.2.0)[error] 7-7: indentation is not a multiple of 4 (E111) [error] 8-8: indentation is not a multiple of 4 (E111) 🤖 Prompt for AI Agents
|
||||||||||||||||||||||
|
||||||||||||||||||||||
def doSomething(self): # N802: function name should be snake_case | ||||||||||||||||||||||
if( self.value>0 ): | ||||||||||||||||||||||
print("Positive") | ||||||||||||||||||||||
else: | ||||||||||||||||||||||
print( "Not positive" ) | ||||||||||||||||||||||
Comment on lines
+10
to
+14
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Fix method naming, spacing, and indentation consistency. The method has multiple violations including naming conventions and inconsistent formatting. - def doSomething(self): # N802: function name should be snake_case
- if( self.value>0 ):
- print("Positive")
- else:
- print( "Not positive" )
+ def do_something(self):
+ if self.value > 0:
+ print("Positive")
+ else:
+ print("Not positive") 📝 Committable suggestion
Suggested change
🧰 Tools🪛 Flake8 (7.2.0)[error] 10-10: indentation is not a multiple of 4 (E111) [error] 12-12: indentation is not a multiple of 4 (E111) [error] 12-12: over-indented (E117) [error] 14-14: indentation is not a multiple of 4 (E111) [error] 14-14: over-indented (E117) 🤖 Prompt for AI Agents
|
||||||||||||||||||||||
|
||||||||||||||||||||||
my_function(1,2) | ||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add proper spacing in function call. The function call needs proper spacing after the comma. -my_function(1,2)
+my_function(1, 2) 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
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.
🛠️ Refactor suggestion
Remove unused imports for cleaner code.
The static analysis tools correctly identify that both
os
andsys
imports remain unused in this file.📝 Committable suggestion
🧰 Tools
🪛 Ruff (0.12.2)
1-1:
os
imported but unusedRemove unused import
(F401)
1-1:
sys
imported but unusedRemove unused import
(F401)
🪛 Flake8 (7.2.0)
[error] 1-1: 'os' imported but unused
(F401)
[error] 1-1: 'sys' imported but unused
(F401)
🤖 Prompt for AI Agents