Skip to content
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 linters to the pull request GitHub action workflows #9

Merged
merged 5 commits into from
Jan 11, 2025

Conversation

palisadoes
Copy link
Contributor

@palisadoes palisadoes commented Jan 11, 2025

Added linters to the pull request GitHub action workflows

Summary by CodeRabbit

Release Notes

  • Code Quality

    • Enhanced code linting and formatting configurations
    • Added docstring validation checks
    • Implemented stricter code style guidelines
  • Development Workflow

    • Updated GitHub Actions workflow with new validation steps
    • Added CodeRabbit.ai review validation
    • Introduced comprehensive docstring compliance checks
  • Dependencies

    • Added new libraries for web development, testing, and code quality
    • Expanded project's tooling support for Flask, data handling, and GraphQL

Copy link

coderabbitai bot commented Jan 11, 2025

Warning

Rate limit exceeded

@palisadoes has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 3 minutes and 22 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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.

📥 Commits

Reviewing files that changed from the base of the PR and between 29d00a2 and 0e3161c.

📒 Files selected for processing (3)
  • .github/workflows/pull-request.yml (2 hunks)
  • .github/workflows/scripts/countline.py (1 hunks)
  • requirements.txt (1 hunks)

Walkthrough

This pull request introduces comprehensive configuration and workflow enhancements for a Python project. The changes focus on improving code quality, documentation standards, and automated checks. New configuration files for linting tools like flake8 and pydocstyle are added, along with a sophisticated GitHub Actions workflow that includes docstring validation, code quality checks, and CodeRabbit.ai approval verification. A custom docstring checking script is introduced to enforce documentation standards, and the requirements.txt is expanded with additional dependencies to support these new processes.

Changes

File Changes
.flake8 Added configuration to ignore specific linting errors and set max line length to 80
.github/workflows/pull-request.yml Added new jobs: Validate-CodeRabbit and Docstring-Compliance; Enhanced Code-Quality-Checks with additional Python and linting tools
.github/workflows/scripts/check_docstrings.py New script for validating Python docstrings against Google style guide with multiple validation functions
.github/workflows/scripts/validate-coderabbit.sh New shell script to validate CodeRabbit.ai PR approvals
.gitignore Improved organization with new sections for ignored files and directories
.pydocstyle Added configuration using Google style guide and ignoring specific docstring errors
pyproject.toml Added Black formatter configuration with 79-character line length
requirements.txt Significant expansion with dependencies for web development, testing, data handling, and code quality tools

Sequence Diagram

sequenceDiagram
    participant PR as Pull Request
    participant GHA as GitHub Actions
    participant QC as Code Quality Checks
    participant DC as Docstring Compliance
    participant CR as CodeRabbit Validation
    
    PR->>GHA: Trigger Workflow
    GHA->>QC: Run Linting and Formatting
    QC-->>GHA: Quality Check Results
    GHA->>DC: Check Docstring Compliance
    DC-->>GHA: Docstring Validation
    GHA->>CR: Validate CodeRabbit Approval
    CR-->>GHA: Approval Status
    GHA->>PR: Workflow Complete
Loading

Poem

🐰 A Rabbit's Code Review Delight

With flake8 and Black, our code shines bright,
Docstrings dancing in Google's pure light,
CodeRabbit hops through each PR with glee,
Checking quality, setting standards free!
Our workflow sings a technological song 🎵


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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

Our Pull Request Approval Process

We have these basic policies to make the approval process smoother for our volunteer team.

Testing Your Code

Please make sure your code passes all tests and there are no merge conflicts.

The process helps maintain accurate and well-formatted documentation and is a prerequisite for getting your PR approved. Assigned reviewers regularly review the PR queue and tend to focus on PRs that are passing.

Reviewers

When your PR has been assigned reviewers contact them to get your code reviewed and approved via:

  1. comments in this PR or
  2. our slack channel

Reviewing Your Code

Your reviewer(s) will have the following roles:

  1. arbitrators of future discussions with other contributors about the validity of your changes
  2. point of contact for evaluating the validity of your work
  3. person who verifies matching issues by others that should be closed.
  4. person who gives general guidance in fixing your tests

CONTRIBUTING.md

Read our CONTRIBUTING.md file. Most importantly:

  1. PRs with issues not assigned to you will be closed by the reviewer
  2. Fix the first comment in the PR so that each issue listed automatically closes

Other

  1. 🎯 Please be considerate of our volunteers' time. Contacting the person who assigned the reviewers is not advised unless they ask for your input. Do not @ the person who did the assignment otherwise.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 7

🧹 Nitpick comments (7)
.github/workflows/scripts/check_docstrings.py (3)

29-35: Use specific exception handling when opening files

Catching a broad Exception can mask unexpected errors and make debugging more difficult. It's better to catch specific exceptions, such as FileNotFoundError.

Apply this diff to handle specific exceptions:

 try:
     with open(file_path, "r", encoding="utf-8") as fh_:
         lines_with_hard_returns = fh_.readlines()

-except Exception:
+except FileNotFoundError:
     return violations
🧰 Tools
🪛 GitHub Actions: PR Workflow

[error] Missing configuration file: No tox.ini, setup.cfg, pyproject.toml, or tox.toml found in the project root


[error] Environment 'flake8' not found in configuration file


53-54: Combine nested if statements into a single condition

The nested if statements at lines 53-54 can be combined into a single condition for better readability.

Apply this diff:

 if bool(decorator):
-    if decorator_in_docstring_exception_list(decorator):
+    if decorator_in_docstring_exception_list(decorator):
         continue

Or combine both conditions:

-if bool(decorator):
-    if decorator_in_docstring_exception_list(decorator):
+if decorator and decorator_in_docstring_exception_list(decorator):
     continue
🧰 Tools
🪛 Ruff (0.8.2)

53-54: Use a single if statement instead of nested if statements

(SIM102)

🪛 GitHub Actions: PR Workflow

[error] Missing configuration file: No tox.ini, setup.cfg, pyproject.toml, or tox.toml found in the project root


[error] Environment 'flake8' not found in configuration file


352-365: Use specific exception handling when parsing docstrings

Catching a broad Exception can mask parsing errors. It's better to catch specific exceptions like ParseError from docstring_parser.

Apply this diff:

 try:
     parser = parse(docstring)

-except Exception as e:
+except ParseError as e:
     violations.append(
         Violation(
             line=docstring_start,
🧰 Tools
🪛 GitHub Actions: PR Workflow

[error] Missing configuration file: No tox.ini, setup.cfg, pyproject.toml, or tox.toml found in the project root


[error] Environment 'flake8' not found in configuration file

.github/workflows/scripts/validate-coderabbit.sh (2)

5-9: Enhance the curl command with proper quoting

The curl command should use proper quoting to handle special characters in variables safely.

Apply this diff:

-response=$(curl -s -f -H "Authorization: token $GITHUB_TOKEN" \
-  "https://api.github.com/repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER}/reviews?per_page=1000") || {
+response=$(curl -s -f -H "Authorization: token ${GITHUB_TOKEN}" \
+  "https://api.github.com/repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER}/reviews?per_page=1000" 2>&1) || {
   echo "Error: Failed to fetch reviews from GitHub API"
+  echo "Details: $response"
   exit 1
 }
🧰 Tools
🪛 GitHub Actions: PR Workflow

[error] Missing configuration file: No tox.ini, setup.cfg, pyproject.toml, or tox.toml found in the project root


[error] Environment 'flake8' not found in configuration file


11-19: Enhance error handling for JSON processing

The error handling could provide more context about the failure.

Apply this diff:

 latest_reviews=$(echo "$response" | jq -c '[.[]] | group_by(.user.login) | map(max_by(.submitted_at))') || {
-  echo "Error: Failed to process reviews JSON"
+  echo "Error: Failed to process reviews JSON. Response was:"
+  echo "$response" | jq '.'
   exit 1
 }

 if [ "$latest_reviews" = "null" ] || [ -z "$latest_reviews" ]; then
-  echo "Error: Invalid reviews data"
+  echo "Error: No reviews found or invalid reviews data"
   exit 1
 fi
🧰 Tools
🪛 GitHub Actions: PR Workflow

[error] Missing configuration file: No tox.ini, setup.cfg, pyproject.toml, or tox.toml found in the project root


[error] Environment 'flake8' not found in configuration file

.gitignore (1)

26-34: Consider uncommenting VS Code settings

The commented VS Code settings could be useful for maintaining consistent editor configurations across the team.

Consider uncommenting these lines if you want to maintain consistent VS Code settings:

-#!.vscode/settings.json
-#!.vscode/tasks.json
-#!.vscode/launch.json
-#!.vscode/extensions.json
-#!.vscode/*.code-snippets
+!.vscode/settings.json
+!.vscode/tasks.json
+!.vscode/launch.json
+!.vscode/extensions.json
+!.vscode/*.code-snippets
🧰 Tools
🪛 GitHub Actions: PR Workflow

[error] Missing configuration file: No tox.ini, setup.cfg, pyproject.toml, or tox.toml found in the project root


[error] Environment 'flake8' not found in configuration file

.github/workflows/pull-request.yml (1)

220-221: Fix trailing whitespace

Remove trailing whitespace to fix yamllint error.

Apply this diff:

-          GITHUB_REPOSITORY: ${{ github.repository }}
-          
+          GITHUB_REPOSITORY: ${{ github.repository }}
🧰 Tools
🪛 yamllint (1.35.1)

[error] 221-221: trailing spaces

(trailing-spaces)

🪛 GitHub Actions: PR Workflow

[error] Missing configuration file: No tox.ini, setup.cfg, pyproject.toml, or tox.toml found in the project root


[error] Environment 'flake8' not found in configuration file

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0c7425c and 29d00a2.

📒 Files selected for processing (8)
  • .flake8 (1 hunks)
  • .github/workflows/pull-request.yml (2 hunks)
  • .github/workflows/scripts/check_docstrings.py (1 hunks)
  • .github/workflows/scripts/validate-coderabbit.sh (1 hunks)
  • .gitignore (1 hunks)
  • .pydocstyle (1 hunks)
  • pyproject.toml (1 hunks)
  • requirements.txt (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • pyproject.toml
  • .flake8
🧰 Additional context used
🪛 GitHub Actions: PR Workflow
.pydocstyle

[error] Missing configuration file: No tox.ini, setup.cfg, pyproject.toml, or tox.toml found in the project root


[error] Environment 'flake8' not found in configuration file

.gitignore

[error] Missing configuration file: No tox.ini, setup.cfg, pyproject.toml, or tox.toml found in the project root


[error] Environment 'flake8' not found in configuration file

.github/workflows/scripts/validate-coderabbit.sh

[error] Missing configuration file: No tox.ini, setup.cfg, pyproject.toml, or tox.toml found in the project root


[error] Environment 'flake8' not found in configuration file

.github/workflows/pull-request.yml

[error] Missing configuration file: No tox.ini, setup.cfg, pyproject.toml, or tox.toml found in the project root


[error] Environment 'flake8' not found in configuration file

requirements.txt

[error] Missing configuration file: No tox.ini, setup.cfg, pyproject.toml, or tox.toml found in the project root


[error] Environment 'flake8' not found in configuration file

.github/workflows/scripts/check_docstrings.py

[error] Missing configuration file: No tox.ini, setup.cfg, pyproject.toml, or tox.toml found in the project root


[error] Environment 'flake8' not found in configuration file

🪛 actionlint (1.7.4)
.github/workflows/pull-request.yml

214-214: shellcheck reported issue in this script: SC2086:info:1:10: Double quote to prevent globbing and word splitting

(shellcheck)


214-214: shellcheck reported issue in this script: SC2086:info:2:1: Double quote to prevent globbing and word splitting

(shellcheck)


233-233: 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)

🪛 yamllint (1.35.1)
.github/workflows/pull-request.yml

[error] 221-221: trailing spaces

(trailing-spaces)

🪛 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)

🔇 Additional comments (2)
.pydocstyle (1)

1-3: ⚠️ Potential issue

Ensure configuration files are recognized by tools

The pipeline is failing with errors indicating missing configuration files. Tools like pydocstyle often expect configurations in files like tox.ini, setup.cfg, or pyproject.toml.

Consider moving the pydocstyle configuration into an appropriate file, such as setup.cfg, to ensure the tool recognizes it.

🧰 Tools
🪛 GitHub Actions: PR Workflow

[error] Missing configuration file: No tox.ini, setup.cfg, pyproject.toml, or tox.toml found in the project root


[error] Environment 'flake8' not found in configuration file

requirements.txt (1)

32-36: ⚠️ Potential issue

Verify flake8 configuration to fix pipeline errors

The pipeline error indicates that the environment 'flake8' is not found in the configuration file. Ensure that flake8 is properly configured in a recognized configuration file like tox.ini, setup.cfg, or pyproject.toml.

Consider adding a setup.cfg file with the following content:

[flake8]
max-line-length = 88
extend-ignore = E203, W503

This will help flake8 recognize the configuration and resolve the pipeline error.

🧰 Tools
🪛 GitHub Actions: PR Workflow

[error] Missing configuration file: No tox.ini, setup.cfg, pyproject.toml, or tox.toml found in the project root


[error] Environment 'flake8' not found in configuration file

Comment on lines +240 to +283
def extract_function_arguments(start, lines):
"""Extract the arguments of a function read from a file.

Args:
start: Starting line to process
lines: List of lines in the file

Returns:
result: Function object

"""
# Initialize key variables
func = ""
possibles = lines[start:]
arguments = []
Function = namedtuple("Function", "name arguments")
method_keywords = ["self", "cls"]

# Process the function
for line in possibles:
if bool(line) is False:
continue
elif ("'''" not in line) and ('"""' not in line):
func = f"{func}{line.strip()}"
else:
break

# Get the arguments
items = func.split("(")[1].split(",")
name = func.split()[1].split("(")[0].strip()
for item in items:
result = item.split(")")[0].split("=")[0].strip()
if bool(result):
arguments.append(result)

# Fix arguments for methods
for keyword in method_keywords:
if keyword in arguments:
arguments.remove(keyword)

# Return
result = Function(name=name, arguments=arguments)
return result

Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Use the ast module to parse function arguments

The extract_function_arguments function uses string manipulation to parse function definitions, which can be fragile and error-prone. Using the ast module provides a more robust solution.

Consider refactoring the function to utilize the ast module:

import ast

def extract_function_arguments(file_content):
    """Extract functions and their arguments using the ast module."""
    Function = namedtuple("Function", "name arguments")
    functions = []
    tree = ast.parse(file_content)
    for node in ast.walk(tree):
        if isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef)):
            func_name = node.name
            arguments = [arg.arg for arg in node.args.args if arg.arg not in ("self", "cls")]
            functions.append(Function(name=func_name, arguments=arguments))
    return functions
🧰 Tools
🪛 GitHub Actions: PR Workflow

[error] Missing configuration file: No tox.ini, setup.cfg, pyproject.toml, or tox.toml found in the project root


[error] Environment 'flake8' not found in configuration file

Comment on lines +162 to +182
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

Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Remove unused loop variable or refactor loop

Similarly, the loop variable argument_docstring at line 162 is not used within the loop body.

Refactor the code to address this issue.

Apply this diff:

-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:

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)

🪛 GitHub Actions: PR Workflow

[error] Missing configuration file: No tox.ini, setup.cfg, pyproject.toml, or tox.toml found in the project root


[error] Environment 'flake8' not found in configuration file

Comment on lines +138 to +158
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

Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Remove unused loop variable or refactor loop

The loop variable argument_function at line 138 is not used within the loop body, which may indicate an issue with the loop's logic.

Consider refactoring the code to eliminate the unnecessary loop or correct the variable usage.

Apply this diff to fix the issue:

-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:

Committable suggestion skipped: line range outside the PR's diff.

🧰 Tools
🪛 Ruff (0.8.2)

138-138: Loop control variable argument_function not used within loop body

(B007)

🪛 GitHub Actions: PR Workflow

[error] Missing configuration file: No tox.ini, setup.cfg, pyproject.toml, or tox.toml found in the project root


[error] Environment 'flake8' not found in configuration file

pytest

# Docstring Parser
docstring_parser
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Remove duplicate dependency 'docstring_parser'

The docstring_parser package is listed twice in requirements.txt at lines 26 and 36.

Apply this diff to remove the duplicate entry:

 # Docstring Parser
 docstring_parser

 # Other
 more-itertools

 #Linting and formatting
 flake8
 flake8-docstrings
 pydocstyle
 black
-docstring_parser

Also applies to: 36-36

🧰 Tools
🪛 GitHub Actions: PR Workflow

[error] Missing configuration file: No tox.ini, setup.cfg, pyproject.toml, or tox.toml found in the project root


[error] Environment 'flake8' not found in configuration file

Comment on lines +1 to +2
#!/bin/bash

Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add environment variable validation

Add validation for required environment variables at the start of the script.

Add this at the beginning of the script:

 #!/bin/bash
+set -e
+
+# Validate required environment variables
+for var in GITHUB_TOKEN PR_NUMBER GITHUB_REPOSITORY; do
+  if [ -z "${!var}" ]; then
+    echo "Error: Required environment variable $var is not set"
+    exit 1
+  fi
+done
+
+# Validate PR_NUMBER is a positive integer
+if ! [[ "$PR_NUMBER" =~ ^[1-9][0-9]*$ ]]; then
+  echo "Error: PR_NUMBER must be a positive integer"
+  exit 1
+fi
📝 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
#!/bin/bash
#!/bin/bash
set -e
# Validate required environment variables
for var in GITHUB_TOKEN PR_NUMBER GITHUB_REPOSITORY; do
if [ -z "${!var}" ]; then
echo "Error: Required environment variable $var is not set"
exit 1
fi
done
# Validate PR_NUMBER is a positive integer
if ! [[ "$PR_NUMBER" =~ ^[1-9][0-9]*$ ]]; then
echo "Error: PR_NUMBER must be a positive integer"
exit 1
fi
🧰 Tools
🪛 GitHub Actions: PR Workflow

[error] Missing configuration file: No tox.ini, setup.cfg, pyproject.toml, or tox.toml found in the project root


[error] Environment 'flake8' not found in configuration file

Comment on lines +71 to +91
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.9

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 black pydocstyle flake8-docstrings

- name: Run Black Formatter Check
run: |
black --check .

- name: Run Flake8 Linter
run: |
flake8 --docstring-convention google switchmap bin setup tests .github --ignore E402,E722,E203,F401,W503

- name: Run pydocstyle
run: |
pydocstyle switchmap setup bin tests --convention=google --add-ignore=D415,D205
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consolidate linting jobs to avoid redundancy

The workflow has multiple jobs running similar checks (Python-Format-Checker, Python-Linter, and linting steps in Code-Quality-Checks).

  1. Remove the redundant jobs and consolidate the checks into Code-Quality-Checks.
  2. Create the missing configuration files to fix the pipeline failures:

Create setup.cfg:

[flake8]
max-line-length = 88
extend-ignore = E402,E722,E203,F401,W503
docstring-convention = google

[pydocstyle]
convention = google
add-ignore = D415,D205
🧰 Tools
🪛 GitHub Actions: PR Workflow

[error] Missing configuration file: No tox.ini, setup.cfg, pyproject.toml, or tox.toml found in the project root


[error] Environment 'flake8' not found in configuration file

Comment on lines +232 to +235
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: 3.11
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Update actions/setup-python to v5

The workflow is using an outdated version of the setup-python action.

Apply this diff:

-      - name: Set up Python 3.11
-        uses: actions/setup-python@v4
+      - name: Set up Python 3.11
+        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.

Suggested change
- 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)

233-233: 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 Actions: PR Workflow

[error] Missing configuration file: No tox.ini, setup.cfg, pyproject.toml, or tox.toml found in the project root


[error] Environment 'flake8' not found in configuration file

@palisadoes palisadoes merged commit d098f0f into PalisadoesFoundation:develop Jan 11, 2025
8 of 9 checks passed
@palisadoes palisadoes deleted the docs branch January 11, 2025 23:58
palisadoes added a commit that referenced this pull request Jan 13, 2025
* Added markdown files

* Updated markdown (#5)

* feat-UI: SM-Docs-API-website (#8)

* Update pull-request.yml

* Update pull-request.yml

* Update pull-request.yml

* Update pull-request.yml

* Update pull-request.yml

* Update pull-request.yml

* Update pull-request.yml

* Create .coderabbit.yaml

* Added linters to the pull request GitHub action workflows (#9)

* Added linters to the pull request GitHub action workflows

* Added linters to the pull request GitHub action workflows

* Fixed flake error

* Fixed black error

* Fixed black error v2

* Update check_docstrings.py

* Json (#10)

* JSON

* Test

* JSON

---------

Co-authored-by: Karthik <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant