-
-
Notifications
You must be signed in to change notification settings - Fork 872
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
Added python script linting #3264
Added python script linting #3264
Conversation
Warning Rate limit exceeded@palisadoes has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 0 minutes and 28 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (1)
WalkthroughThis pull request introduces comprehensive code quality and style enforcement mechanisms for Python projects. It adds configuration files for tools like Flake8, Black, and pydocstyle to standardize code formatting and documentation. A new GitHub Actions workflow job called Changes
Suggested labels
Suggested reviewers
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
Our Pull Request Approval ProcessThanks for contributing! Testing Your CodeRemember, your PRs won't be reviewed until these criteria are met:
Our policies make our code better. ReviewersDo not assign reviewers. Our Queue Monitors will review your PR and assign them.
Reviewing Your CodeYour reviewer(s) will have the following roles:
CONTRIBUTING.mdRead our CONTRIBUTING.md file. Most importantly:
Other
|
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.
Actionable comments posted: 4
🧹 Nitpick comments (10)
.github/workflows/scripts/check_docstrings.py (2)
53-54
: Simplify nestedif
statements into a single conditionAt lines 53-54, the nested
if
statements can be combined into a singleif
statement for better readability.Apply this diff to simplify the code:
- if bool(decorator): - if decorator_in_docstring_exception_list(decorator): + if decorator and decorator_in_docstring_exception_list(decorator):🧰 Tools
🪛 Ruff (0.8.2)
53-54: Use a single
if
statement instead of nestedif
statements(SIM102)
240-283
: Consider using theast
module for robust function parsingThe
extract_function_arguments
function manually parses function definitions using string manipulation, which may not handle complex cases like decorators, annotations, or multiline definitions.Refactor the function to use the
ast
module for accurate parsing. Here's an example:import ast def extract_function_arguments(start, lines): Function = namedtuple("Function", "name arguments") function_code = ''.join(lines[start:]) try: node = ast.parse(function_code) for elem in node.body: if isinstance(elem, ast.FunctionDef): arguments = [arg.arg for arg in elem.args.args if arg.arg not in ('self', 'cls')] return Function(name=elem.name, arguments=arguments) except SyntaxError: pass return Function(name='', arguments=[])This approach ensures that all function definitions are parsed correctly, improving maintainability and reducing errors.
.github/workflows/scripts/eslint_disable_check.py (2)
105-106
: OmitArgs
section when there are no argumentsIn the
arg_parser_resolver()
function's docstring (lines 105-106), you includeArgs: None
. According to the Google Python Style Guide, you can omit theArgs
section if the function doesn't accept any arguments.Apply this diff to simplify the docstring:
- Args: None
Line range hint
131-160
: Remove unnecessaryArgs
andReturns
sectionsIn the
main()
function's docstring (lines 131-160), theArgs: None
andReturns: None
sections are not needed and can be omitted for brevity.Apply this diff to clean up the docstring:
- Args: - None - - Returns: - None -.github/workflows/scripts/code_coverage_disable_check.py (2)
118-120
: OmitArgs
section when no arguments are presentIn
arg_parser_resolver()
function's docstring (lines 118-120), you includeArgs:
with no arguments listed. It's recommended to omit this section if there are no arguments.Apply this diff:
- Args: - None
Line range hint
145-160
: Remove unnecessaryArgs
andReturns
sectionsThe
main()
function's docstring (lines 145-160) includesArgs: None
andReturns: None
, which are unnecessary when there are no arguments or return values.Apply this diff to streamline the docstring:
- Args: - None - - Returns: - None.github/workflows/scripts/compare_translations.py (2)
Line range hint
1-51
: Improve module docstring structure.The docstring structure could be enhanced by:
- Moving implementation details from "Methodology" to a new "Implementation" section
- Removing the redundant "Note" section about compliance standards
"""Script to encourage more efficient coding practices. Methodology: - Utility for comparing translations between default and other languages. + This utility ensures consistency across language translations by comparing + translation files against a default language file. + +Implementation: This module defines a function to compare two translations and print any missing keys in the other language's translation. Attributes: FileTranslation : Named tuple to represent a combination of file and missing translations. ... -Note: - This script complies with our python3 coding and documentation standards - and should be used as a reference guide. It complies with: - - 1) Pylint - 2) Pydocstyle - 3) Pycodestyle - 4) Flake8 """🧰 Tools
🪛 GitHub Check: Performs linting, formatting, type-checking, checking for different source and target branch
[warning] 1-1:
File ignored by default.
87-89
: Simplify error message formatting.The error messages use unnecessary backslash line continuation. F-strings can span multiple lines within parentheses.
- error_msg = f"""\ -Missing Key: '{key}' - This key from '{default_file}' \ -is missing in '{other_file}'.""" + error_msg = ( + f"Missing Key: '{key}' - This key from '{default_file}' " + f"is missing in '{other_file}'" + ) - error_msg = f"""\ -Error Key: '{key}' - This key in '{other_file}' \ -does not match any key in '{default_file}'.""" + error_msg = ( + f"Error Key: '{key}' - This key in '{other_file}' " + f"does not match any key in '{default_file}'" + )Also applies to: 95-97
.github/workflows/pull-request.yml (1)
491-493
: Expand Flake8 check scope.The Flake8 check is currently limited to the .github directory. Consider expanding it to check all Python files in the repository.
- flake8 --docstring-convention google --ignore E402,E722,E203,F401,W503 .github + flake8 --docstring-convention google --ignore E402,E722,E203,F401,W503 ..pydocstyle (1)
1-3
: Consider enforcing D415 for better docstring quality.D415 ensures that the first line of docstrings ends with a period, which promotes proper sentence structure. Consider removing it from the ignore list unless there's a specific reason to ignore it.
[pydocstyle] convention=google -add-ignore=D415,D205 +add-ignore=D205🧰 Tools
🪛 GitHub Check: Performs linting, formatting, type-checking, checking for different source and target branch
[warning] 1-1:
File ignored by default.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (11)
.flake8
(1 hunks).github/workflows/pull-request.yml
(2 hunks).github/workflows/requirements.txt
(1 hunks).github/workflows/scripts/check_docstrings.py
(1 hunks).github/workflows/scripts/code_coverage_disable_check.py
(9 hunks).github/workflows/scripts/compare_translations.py
(9 hunks).github/workflows/scripts/countline.py
(1 hunks).github/workflows/scripts/eslint_disable_check.py
(6 hunks).github/workflows/scripts/talawa_admin_md_mdx_format_adjuster.py
(0 hunks).pydocstyle
(1 hunks)pyproject.toml
(1 hunks)
💤 Files with no reviewable changes (1)
- .github/workflows/scripts/talawa_admin_md_mdx_format_adjuster.py
✅ Files skipped from review due to trivial changes (2)
- pyproject.toml
- .github/workflows/scripts/countline.py
🧰 Additional context used
🪛 GitHub Check: Performs linting, formatting, type-checking, checking for different source and target branch
.github/workflows/requirements.txt
[warning] 1-1:
File ignored by default.
.github/workflows/scripts/check_docstrings.py
[warning] 1-1:
File ignored by default.
.flake8
[warning] 1-1:
File ignored by default.
.pydocstyle
[warning] 1-1:
File ignored by default.
🪛 GitHub Actions: PR Workflow
.github/workflows/requirements.txt
[warning] File ignored by default. Use a negated ignore pattern (like "--ignore-pattern '!<relative/path/to/filename>'")
.github/workflows/pull-request.yml
[warning] File ignored by default. Use a negated ignore pattern (like "--ignore-pattern '!<relative/path/to/filename>'")
.github/workflows/scripts/eslint_disable_check.py
[warning] File ignored by default. Use a negated ignore pattern (like "--ignore-pattern '!<relative/path/to/filename>'")
.github/workflows/scripts/compare_translations.py
[warning] File ignored by default. Use a negated ignore pattern (like "--ignore-pattern '!<relative/path/to/filename>'")
.github/workflows/scripts/code_coverage_disable_check.py
[warning] File ignored by default. Use a negated ignore pattern (like "--ignore-pattern '!<relative/path/to/filename>'")
.github/workflows/scripts/check_docstrings.py
[warning] File ignored by default. Use a negated ignore pattern (like "--ignore-pattern '!<relative/path/to/filename>'")
.flake8
[warning] File ignored by default. Use a negated ignore pattern (like "--ignore-pattern '!<relative/path/to/filename>'")
.pydocstyle
[warning] File ignored by default. Use a negated ignore pattern (like "--ignore-pattern '!<relative/path/to/filename>'")
🪛 actionlint (1.7.4)
.github/workflows/pull-request.yml
468-468: the runner of "actions/setup-python@v4" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
🪛 Ruff (0.8.2)
.github/workflows/scripts/check_docstrings.py
53-54: Use a single if
statement instead of nested if
statements
(SIM102)
138-138: Loop control variable argument_function
not used within loop body
(B007)
162-162: Loop control variable argument_docstring
not used within loop body
(B007)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Analyse Code With CodeQL (javascript)
🔇 Additional comments (2)
.flake8 (2)
3-3
: The max line length of 80 characters is reasonable.Setting max-line-length to 80 characters is a widely accepted standard that:
- Ensures code readability across different environments
- Allows side-by-side file comparison
- Works well with most terminal windows
1-3
: Consider documenting and reviewing ignored error codes.While ignoring certain Flake8 errors can be necessary, some of the ignored codes could hide important issues:
E722
: Ignoring bareexcept
clauses can mask errors and complicate debuggingF401
: Ignoring unused imports can lead to code bloatConsider:
- Documenting the rationale for each ignored error code in comments
- Gradually addressing these issues in the codebase instead of ignoring them
- Only ignoring specific error codes where absolutely necessary
Let's check the codebase for instances of bare except clauses and unused imports:
🧰 Tools
🪛 GitHub Check: Performs linting, formatting, type-checking, checking for different source and target branch
[warning] 1-1:
File ignored by default.
for argument_function in arguments_function: | ||
# Track whether the argument is defined | ||
# in the docstring parameters | ||
for argument_docstring in arguments_docstring: | ||
if argument_docstring not in arguments_function: | ||
violations.append( | ||
Violation( | ||
line=line_number + 1, | ||
function=function.name, | ||
issue=f"""\ | ||
Argument '{argument_docstring}' defined in the docstring is not \ | ||
an argument in the function""", | ||
action=f"""\ | ||
Remove argument '{argument_docstring}' from the docstring""", | ||
) | ||
) | ||
bad_argument_function = True | ||
break | ||
if bad_argument_function: | ||
break |
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 loop variable argument_function
The loop variable argument_function
at line 138 is not used within the loop body, which may lead to confusion.
Apply this diff to fix the issue:
- for argument_function in arguments_function:
+ for _ in arguments_function:
Alternatively, refactor the code to remove the unnecessary loop if it's not needed.
📝 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.
for argument_function in arguments_function: | |
# Track whether the argument is defined | |
# in the docstring parameters | |
for argument_docstring in arguments_docstring: | |
if argument_docstring not in arguments_function: | |
violations.append( | |
Violation( | |
line=line_number + 1, | |
function=function.name, | |
issue=f"""\ | |
Argument '{argument_docstring}' defined in the docstring is not \ | |
an argument in the function""", | |
action=f"""\ | |
Remove argument '{argument_docstring}' from the docstring""", | |
) | |
) | |
bad_argument_function = True | |
break | |
if bad_argument_function: | |
break | |
for _ in arguments_function: | |
# Track whether the argument is defined | |
# in the docstring parameters | |
for argument_docstring in arguments_docstring: | |
if argument_docstring not in arguments_function: | |
violations.append( | |
Violation( | |
line=line_number + 1, | |
function=function.name, | |
issue=f"""\ | |
Argument '{argument_docstring}' defined in the docstring is not \ | |
an argument in the function""", | |
action=f"""\ | |
Remove argument '{argument_docstring}' from the docstring""", | |
) | |
) | |
bad_argument_function = True | |
break | |
if bad_argument_function: | |
break |
🧰 Tools
🪛 Ruff (0.8.2)
138-138: Loop control variable argument_function
not used within loop body
(B007)
for argument_docstring in arguments_docstring: | ||
# Track whether the argument is defined | ||
# in the function parameters | ||
for argument_function in arguments_function: | ||
if argument_function not in arguments_docstring: | ||
violations.append( | ||
Violation( | ||
line=line_number + 1, | ||
function=function.name, | ||
issue=f"""\ | ||
Argument '{argument_function}' defined in the function is not \ | ||
an argument in the docstring""", | ||
action=f"""\ | ||
Add argument '{argument_function}' to the Docstring""", | ||
) | ||
) | ||
bad_argument_docstring = True | ||
break | ||
if bad_argument_docstring: | ||
break |
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 loop variable argument_docstring
Similarly, at line 162, the loop variable argument_docstring
is not used within the loop body.
Apply this diff to fix the issue:
- for argument_docstring in arguments_docstring:
+ for _ in arguments_docstring:
Consider adjusting the logic to utilize the loop variable appropriately or eliminate the loop if it's unnecessary.
Committable suggestion skipped: line range outside the PR's diff.
🧰 Tools
🪛 Ruff (0.8.2)
162-162: Loop control variable argument_docstring
not used within loop body
(B007)
black | ||
pydocstyle | ||
flake8 | ||
flake8-docstrings | ||
docstring_parser |
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
Pin package versions for reproducible builds.
Dependencies should have version constraints to ensure reproducible builds and avoid breaking changes.
-black
-pydocstyle
-flake8
-flake8-docstrings
-docstring_parser
+black==24.1.1
+pydocstyle==6.3.0
+flake8==7.0.0
+flake8-docstrings==1.7.0
+docstring_parser==0.15
📝 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.
black | |
pydocstyle | |
flake8 | |
flake8-docstrings | |
docstring_parser | |
black==24.1.1 | |
pydocstyle==6.3.0 | |
flake8==7.0.0 | |
flake8-docstrings==1.7.0 | |
docstring_parser==0.15 |
- name: Set up Python 3.11 | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.11 |
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
Update setup-python action to latest version.
The setup-python action version is outdated.
- uses: actions/setup-python@v4
+ uses: actions/setup-python@v5
with:
python-version: 3.11
📝 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.
- name: Set up Python 3.11 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.11 | |
- name: Set up Python 3.11 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.11 |
🧰 Tools
🪛 actionlint (1.7.4)
468-468: the runner of "actions/setup-python@v4" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop-postgres #3264 +/- ##
=====================================================
+ Coverage 8.49% 90.27% +81.78%
=====================================================
Files 309 330 +21
Lines 7831 8491 +660
Branches 1730 1875 +145
=====================================================
+ Hits 665 7665 +7000
+ Misses 7092 598 -6494
- Partials 74 228 +154 ☔ View full report in Codecov by Sentry. |
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.
Actionable comments posted: 2
🧹 Nitpick comments (1)
.github/workflows/scripts/check_docstrings.py (1)
201-206
: Simplify decorator check logic.The nested if statements can be combined for better readability.
Apply this diff to simplify the code:
- if start > 0: - previous_line = lines[start - 1].strip() - if previous_line.startswith("@"): - result = previous_line + result = lines[start - 1].strip() if start > 0 and lines[start - 1].strip().startswith("@") else None
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
.github/workflows/pull-request.yml
(2 hunks).github/workflows/scripts/check_docstrings.py
(1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/pull-request.yml
468-468: the runner of "actions/setup-python@v4" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
🪛 Ruff (0.8.2)
.github/workflows/scripts/check_docstrings.py
53-54: Use a single if
statement instead of nested if
statements
(SIM102)
138-138: Loop control variable argument_function
not used within loop body
(B007)
162-162: Loop control variable argument_docstring
not used within loop body
(B007)
🪛 GitHub Check: Performs linting, formatting, type-checking, checking for different source and target branch
.github/workflows/scripts/check_docstrings.py
[warning] 1-1:
File ignored by default.
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Test Application
- GitHub Check: Analyse Code With CodeQL (javascript)
🔇 Additional comments (4)
.github/workflows/pull-request.yml (3)
99-101
: LGTM! Python linting configuration files added to sensitive files list.The Python linting configuration files are correctly added to the list of sensitive files that require authorization for changes.
457-461
: LGTM! Python-Compliance job correctly configured.The job is properly integrated into the workflow with appropriate dependencies.
467-470
: Update setup-python action to latest version.The setup-python action version is outdated.
Apply this diff to update the action:
- uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: 3.11🧰 Tools
🪛 actionlint (1.7.4)
468-468: the runner of "actions/setup-python@v4" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
.github/workflows/scripts/check_docstrings.py (1)
1-11
: LGTM! Script header and imports are well-structured.The script has appropriate imports and a clear namedtuple definition for violations.
🧰 Tools
🪛 GitHub Check: Performs linting, formatting, type-checking, checking for different source and target branch
[warning] 1-1:
File ignored by default.
default=".", | ||
nargs="+", | ||
type=str, | ||
help="Directory where the cache files are located.", |
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.
Fix CLI argument help message.
The help message incorrectly refers to cache files instead of describing the directory to scan for Python files.
Apply this diff to fix the help message:
- help="Directory where the cache files are located.",
+ help="Directories to scan for Python files to check docstring compliance.",
📝 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.
help="Directory where the cache files are located.", | |
help="Directories to scan for Python files to check docstring compliance.", |
# Check whether docstring arguments match function arguments | ||
for argument_function in arguments_function: | ||
# Track whether the argument is defined | ||
# in the docstring parameters | ||
for argument_docstring in arguments_docstring: | ||
if argument_docstring not in arguments_function: | ||
violations.append( | ||
Violation( | ||
line=line_number + 1, | ||
function=function.name, | ||
issue=f"""\ | ||
Argument '{argument_docstring}' defined in the docstring is not \ | ||
an argument in the function""", | ||
action=f"""\ | ||
Remove argument '{argument_docstring}' from the docstring""", | ||
) | ||
) | ||
bad_argument_function = True | ||
break | ||
if bad_argument_function: | ||
break | ||
|
||
# We found an error, no need to continue generating violations | ||
if not bad_argument_function: | ||
# Check whether docstring arguments match function arguments | ||
for argument_docstring in arguments_docstring: | ||
# Track whether the argument is defined | ||
# in the function parameters | ||
for argument_function in arguments_function: | ||
if argument_function not in arguments_docstring: | ||
violations.append( | ||
Violation( | ||
line=line_number + 1, | ||
function=function.name, | ||
issue=f"""\ | ||
Argument '{argument_function}' defined in the function is not \ | ||
an argument in the docstring""", | ||
action=f"""\ | ||
Add argument '{argument_function}' to the Docstring""", | ||
) | ||
) | ||
bad_argument_docstring = True | ||
break | ||
if bad_argument_docstring: | ||
break | ||
|
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
Simplify nested loops and fix unused variables.
The nested loops can be simplified, and there are unused loop variables that should be addressed.
Apply this diff to improve the code:
- for argument_function in arguments_function:
- # Track whether the argument is defined
- # in the docstring parameters
- for argument_docstring in arguments_docstring:
+ # Check for arguments in docstring that aren't in function
+ for argument_docstring in arguments_docstring:
+ if argument_docstring not in arguments_function:
+ violations.append(
+ Violation(
+ line=line_number + 1,
+ function=function.name,
+ issue=f"Argument '{argument_docstring}' defined in the docstring is not an argument in the function",
+ action=f"Remove argument '{argument_docstring}' from the docstring",
+ )
+ )
+ break
+ # Check for arguments in function that aren't in docstring
+ for argument_function in arguments_function:
+ if argument_function not in arguments_docstring:
+ violations.append(
+ Violation(
+ line=line_number + 1,
+ function=function.name,
+ issue=f"Argument '{argument_function}' defined in the function is not an argument in the docstring",
+ action=f"Add argument '{argument_function}' to the Docstring",
+ )
+ )
+ break
📝 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.
# Check whether docstring arguments match function arguments | |
for argument_function in arguments_function: | |
# Track whether the argument is defined | |
# in the docstring parameters | |
for argument_docstring in arguments_docstring: | |
if argument_docstring not in arguments_function: | |
violations.append( | |
Violation( | |
line=line_number + 1, | |
function=function.name, | |
issue=f"""\ | |
Argument '{argument_docstring}' defined in the docstring is not \ | |
an argument in the function""", | |
action=f"""\ | |
Remove argument '{argument_docstring}' from the docstring""", | |
) | |
) | |
bad_argument_function = True | |
break | |
if bad_argument_function: | |
break | |
# We found an error, no need to continue generating violations | |
if not bad_argument_function: | |
# Check whether docstring arguments match function arguments | |
for argument_docstring in arguments_docstring: | |
# Track whether the argument is defined | |
# in the function parameters | |
for argument_function in arguments_function: | |
if argument_function not in arguments_docstring: | |
violations.append( | |
Violation( | |
line=line_number + 1, | |
function=function.name, | |
issue=f"""\ | |
Argument '{argument_function}' defined in the function is not \ | |
an argument in the docstring""", | |
action=f"""\ | |
Add argument '{argument_function}' to the Docstring""", | |
) | |
) | |
bad_argument_docstring = True | |
break | |
if bad_argument_docstring: | |
break | |
# Check for arguments in docstring that aren't in function | |
for argument_docstring in arguments_docstring: | |
if argument_docstring not in arguments_function: | |
violations.append( | |
Violation( | |
line=line_number + 1, | |
function=function.name, | |
issue=f"Argument '{argument_docstring}' defined in the docstring is not an argument in the function", | |
action=f"Remove argument '{argument_docstring}' from the docstring", | |
) | |
) | |
break | |
# Check for arguments in function that aren't in docstring | |
for argument_function in arguments_function: | |
if argument_function not in arguments_docstring: | |
violations.append( | |
Violation( | |
line=line_number + 1, | |
function=function.name, | |
issue=f"Argument '{argument_function}' defined in the function is not an argument in the docstring", | |
action=f"Add argument '{argument_function}' to the Docstring", | |
) | |
) | |
break |
🧰 Tools
🪛 Ruff (0.8.2)
138-138: Loop control variable argument_function
not used within loop body
(B007)
162-162: Loop control variable argument_docstring
not used within loop body
(B007)
d3657e1
into
PalisadoesFoundation:develop-postgres
What kind of change does this PR introduce?
Added python script linting
Issue Number:
Snapshots/Videos:
If relevant, did you update the documentation?
Summary
Added linting to ensure standardization in the python scripts we use in the repository
Does this PR introduce a breaking change?
Other information
Have you read the contributing guide?
Summary by CodeRabbit
New Features
Documentation
Chores