Skip to content

Backend test - #104

Open
jayam04 wants to merge 73 commits into
jayam04:developfrom
pritesh299:backend_test
Open

jayam04 wants to merge 73 commits into
jayam04:developfrom
pritesh299:backend_test

Conversation

@jayam04

@jayam04 jayam04 commented Apr 25, 2026

Copy link
Copy Markdown
Owner

Overview

  1. This PR fixes #[fill_in_number_here] or fixes part of #[fill_in_number_here].
  2. This PR does the following: [Explain here what your PR does and why]
  3. (For bug-fixing PRs only) The original bug occurred because: [Explain what
    the cause of the bug was, and which PR introduced it]

Essential Checklist

Please follow the instructions for making a code change.

  • I have linked the issue that this PR fixes in the "Development" section of the sidebar.
  • I have checked the "Files Changed" tab and confirmed that the changes are what I want to make.
  • I have written tests for my code.
  • The PR title starts with "Fix #bugnum: " or "Fix part of #bugnum: ...", followed by a short, clear summary of the changes.
  • I have assigned the correct reviewers to this PR (or will leave a comment with the phrase "@{{reviewer_username}} PTAL" if I can't assign them directly).

Testing doc (for PRs with Beam jobs that modify production server data)

  • A testing doc has been written: ... (ADD LINK) ...
  • (To be confirmed by the server admin) All jobs in this PR have been verified on a live server, and the PR is safe to merge.

Proof that changes are correct

Proof of changes on desktop with slow/throttled network

Proof of changes on mobile phone

Proof of changes in Arabic language

PR Pointers

Summary by CodeRabbit

  • Tests
    • Enhanced test coverage for linting checkers with additional edge case scenarios and error handling validation across multiple checker types.

@coderabbitai

coderabbitai Bot commented Apr 25, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 005c9f19-0842-4759-97e5-dd3245188ee0

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Test coverage is expanded for custom pylint checkers and linter functionality. The first file adds comprehensive unit tests for six custom checkers (HangingIndentChecker, DocstringParameterChecker, InequalityWithNoneChecker, DisallowHandlerWithoutSchemaChecker, DisallowedImportsChecker, PreventStringConcatenationChecker) and a RegisterFunctionTests suite. The second file adds three new test scenarios for linter selection, file exclusion, and duplicate detection.

Changes

Cohort / File(s) Summary
Pylint Extensions Test Coverage
scripts/linters/pylint_extensions_test.py
Adds comprehensive unit tests for six custom pylint checkers covering edge-case tokenization/AST patterns, including inline comments, missing docstrings, inequality comparisons, class handling, import restrictions, and string concatenation operators. Introduces RegisterFunctionTests to verify the register() function installs all expected checkers into a PyLinter instance.
Linter Check Scenarios
scripts/linters/run_lint_checks_test.py
Updates test fixture nesting for test_get_changed_filepaths and adds three new test cases: linter selection for unhandled file extensions, glob-matched file exclusion during directory enumeration, and RuntimeError detection for duplicate filepaths across shards.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 Hop, hop, lint and test with care,
Each checker now has cases rare,
Edge cases caught, no more gaps to bear,
Our code now passes the inspection snare!

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 43.75% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The pull request title 'Backend test' is too vague and generic. It does not clearly convey the specific changes made, which involve expanding test coverage for multiple pylint extension checkers and run_lint_checks functionality. Provide a more descriptive title that specifically identifies the main changes, such as 'Expand test coverage for pylint extensions and run_lint_checks' or 'Add comprehensive unit tests for custom pylint checkers'.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@jayam04

jayam04 commented Apr 25, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Apr 25, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@scripts/linters/pylint_extensions_test.py`:
- Around line 5252-5270: The two tests testing "from typing import Text" are
redundant: either remove test_visit_importfrom_adds_message_for_text_import or
change it to cover a distinct case (e.g., multi-name import or aliased import)
so it does not duplicate
test_importing_text_from_typing_in_single_line_raises_error; update or rename
test_visit_importfrom_adds_message_for_text_import (and its assertion) to assert
a different behavior such as handling "from typing import Text as T" or "from
typing import Text, Other" using visit_importfrom, or delete it if redundant,
keeping test_visit_importfrom_returns_early_for_non_typing_import intact.

In `@scripts/linters/run_lint_checks_test.py`:
- Line 28: The import line "from typing import Dict, List, Optional" creates
inconsistent usage with newer annotations used later (e.g., list[tuple[...]]) —
change the type imports and annotations to use modern built-in generics: replace
Dict and List usages with dict and list in annotations (and optionally replace
Optional[T] with T | None or keep Optional if you prefer), and remove Dict/List
from the import statement so all type hints (including any annotations
referenced in functions or variables) consistently use the built-in dict/list
forms; update any annotations referenced in functions like any test helpers or
fixtures that currently use List[...] or Dict[...] to the built-in equivalents.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 02cc8ed3-b463-4fbc-8f05-adb45a47d075

📥 Commits

Reviewing files that changed from the base of the PR and between 88d95b5 and f78a5b4.

📒 Files selected for processing (2)
  • scripts/linters/pylint_extensions_test.py
  • scripts/linters/run_lint_checks_test.py

Comment on lines +5252 to +5270
def test_visit_importfrom_adds_message_for_text_import(self) -> None:

import_node = astroid.extract_node('from typing import Text')

with self.checker_test_object.assertAddsMessages(
testutils.MessageTest(
msg_id='disallowed-text-import',
node=import_node,
),
ignore_position=True,
):
self.checker_test_object.checker.visit_importfrom(import_node)

def test_visit_importfrom_returns_early_for_non_typing_import(self) -> None:

import_node = astroid.extract_node('from os import path')

with self.checker_test_object.assertNoMessages():
self.checker_test_object.checker.visit_importfrom(import_node)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Minor redundancy with existing test.

The test_visit_importfrom_adds_message_for_text_import test (lines 5252-5263) is very similar to the existing test_importing_text_from_typing_in_single_line_raises_error test (lines 5212-5223). Both test from typing import Text. Consider consolidating or differentiating the test names to clarify the unique purpose of each.

The test_visit_importfrom_returns_early_for_non_typing_import is a good negative test case.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@scripts/linters/pylint_extensions_test.py` around lines 5252 - 5270, The two
tests testing "from typing import Text" are redundant: either remove
test_visit_importfrom_adds_message_for_text_import or change it to cover a
distinct case (e.g., multi-name import or aliased import) so it does not
duplicate test_importing_text_from_typing_in_single_line_raises_error; update or
rename test_visit_importfrom_adds_message_for_text_import (and its assertion) to
assert a different behavior such as handling "from typing import Text as T" or
"from typing import Text, Other" using visit_importfrom, or delete it if
redundant, keeping test_visit_importfrom_returns_early_for_non_typing_import
intact.

from core.tests import test_utils

from typing import List, Optional
from typing import Dict, List, Optional

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Consider using modern built-in generic types for consistency.

"The generic aliases in the typing module are considered deprecated and type checkers may warn if they are used." While the existing codebase uses List from typing throughout this file, the new code at line 388 uses the modern list[tuple[...]] syntax. This creates an inconsistency.

Given that the rest of the file uses the older style, this is acceptable for maintaining consistency with existing patterns, but consider migrating the entire file to modern syntax (dict, list) in a future cleanup.

🧰 Tools
🪛 Ruff (0.15.11)

[warning] 28-28: typing.Dict is deprecated, use dict instead

(UP035)


[warning] 28-28: typing.List is deprecated, use list instead

(UP035)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@scripts/linters/run_lint_checks_test.py` at line 28, The import line "from
typing import Dict, List, Optional" creates inconsistent usage with newer
annotations used later (e.g., list[tuple[...]]) — change the type imports and
annotations to use modern built-in generics: replace Dict and List usages with
dict and list in annotations (and optionally replace Optional[T] with T | None
or keep Optional if you prefer), and remove Dict/List from the import statement
so all type hints (including any annotations referenced in functions or
variables) consistently use the built-in dict/list forms; update any annotations
referenced in functions like any test helpers or fixtures that currently use
List[...] or Dict[...] to the built-in equivalents.

@testbot-oppiabot

Copy link
Copy Markdown

Hi @DubeySandeep, @oppia/web-tech-leads I cannot decide what to do with this PR, please assign reviewers manually thanks!

2 similar comments
@testbot-oppiabot

Copy link
Copy Markdown

Hi @DubeySandeep, @oppia/web-tech-leads I cannot decide what to do with this PR, please assign reviewers manually thanks!

@testbot-oppiabot

Copy link
Copy Markdown

Hi @DubeySandeep, @oppia/web-tech-leads I cannot decide what to do with this PR, please assign reviewers manually thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants