-
Notifications
You must be signed in to change notification settings - Fork 3
Ruff Showcase #3
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,17 @@ | ||||||||||||||||||||||
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. Fix spacing and formatting issues in the function definition. The function definition contains multiple formatting problems: excessive spaces around parameters, inconsistent spacing in the print statement, and missing space after the comma in the addition operation. -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
🤖 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. Follow Python naming conventions and fix spacing issues. The class name violates Python naming conventions (should use CapWords), and the assignment operator lacks proper whitespace. -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
🤖 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. Apply snake_case naming and fix formatting inconsistencies. The method name violates Python naming conventions (should use snake_case), and the conditional statement has spacing issues and inconsistent indentation. - 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
🤖 Prompt for AI Agents
|
||||||||||||||||||||||
|
||||||||||||||||||||||
my_function(1,2) | ||||||||||||||||||||||
|
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.
Remove unused imports to clean up the code.
Both
os
andsys
modules are imported but never used in the code. Remove these unused imports to improve code clarity and pass static analysis checks.-import os, sys # F401: sys imported but unused
📝 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)
🤖 Prompt for AI Agents