Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10"]
python-version: ["3.8", "3.9", "3.10"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
Expand Down
10 changes: 6 additions & 4 deletions demo.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
def my_function():
"""Demo module for hello function."""

a = 5
return a

def hello():
"""Return a demo greeting message."""
return "hello dosto"

my_function()

hello()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Top-level call executes on import and its return value is discarded

Calling hello() at module import time can cause side effects when the module is imported elsewhere and the result is silently ignored.
Wrap the invocation in a __main__ guard and explicitly use the returned string (e.g. print it).

-hello()
+if __name__ == "__main__":
+    print(hello())
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
hello()
if __name__ == "__main__":
print(hello())
🤖 Prompt for AI Agents
In demo.py at line 8, the call to hello() is executed at import time and its
return value is discarded, which can cause unintended side effects. To fix this,
wrap the call to hello() inside an if __name__ == "__main__": block and
explicitly handle the return value, for example by printing it.

1 change: 1 addition & 0 deletions testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
This module contains a simple hello function.
"""


def hello():
"""
This function returns a greeting message.
Expand Down