Skip to content

Fix deque module name for test_repr #5799

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

Merged
merged 2 commits into from
Jun 15, 2025
Merged

Conversation

youknowone
Copy link
Member

@youknowone youknowone commented Jun 6, 2025

Summary by CodeRabbit

  • Bug Fixes

    • Tests that previously were expected to fail now run as normal tests, improving reliability of test results.
    • A specific test is now skipped on macOS to avoid inconsistent test outcomes on that platform.
  • Refactor

    • Improved internal association of certain classes with their respective modules, enhancing consistency within the Python environment.

Copy link

coderabbitai bot commented Jun 6, 2025

Walkthrough

The updates adjust test expectations and module associations for the deque type. Tests involving deque docstrings and container representations are now expected to pass. A test in test_httplib.py is skipped on macOS. The PyDeque class is explicitly linked to the collections module in its Rust implementation.

Changes

File(s) Change Summary
Lib/test/test_dataclasses.py Removed @unittest.expectedFailure and related comments from two TestDocString test methods.
Lib/test/test_reprlib.py Removed @unittest.expectedFailure and related comment from test_container in ReprTests.
Lib/test/test_httplib.py Added @unittest.skipIf to skip a test on macOS in HTTPSTest; imported sys module.
vm/src/stdlib/collections.rs Added module = "collections" attribute to #[pyclass] for PyDeque.

Poem

In the garden of tests, some failures have flown,
Now deque’s true home is clearly shown.
Mac skips a test, reprlib’s in line,
The docstrings are tidy, everything’s fine!
With a hop and a skip, the rabbit’s delight—
The code grows more polished, from morning to night.
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

@youknowone
Copy link
Member Author

flaky or something changed?

======================================================================
UNEXPECTED SUCCESS: test_local_unknown_cert (test.test_httplib.HTTPSTest.test_local_unknown_cert)
----------------------------------------------------------------------

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

🔭 Outside diff range comments (1)
Lib/test/test_httplib.py (1)

183-186: 💡 Verification agent

🧩 Analysis chain

Stacking expectedFailure + skipIf may mask future fixes
The test is now wrapped as expectedFailure(skipIf(test)), meaning:
• on macOS it is skipped,
• on other platforms it still expects to fail.

If the underlying bug eventually gets fixed, the expected-failure wrapper will silently swallow the success everywhere except macOS, so the CI will not alert you.
Two alternatives:

-@unittest.expectedFailure
-@unittest.skipIf(sys.platform == 'darwin', 'Occasionally success on macOS')
+@unittest.skipIf(sys.platform == 'darwin',
+                 'Flaky on macOS – see issue ####')
+# Drop expectedFailure once the root cause is fixed everywhere

—or— drop expectedFailure entirely and rely solely on skipIf until the flakiness is understood.

Either way the intent becomes clearer and future green runs will surface the fix.


I’d like to confirm how the decorators are applied in Lib/test/test_httplib.py to ensure the advice is accurate. Let’s pull in the surrounding lines for both decorators:


🏁 Script executed:

#!/bin/bash
# Show skipIf decorator and its context
rg -n -A2 "@unittest\.skipIf" Lib/test/test_httplib.py

# Show expectedFailure decorator and its context
rg -n -A2 "@unittest\.expectedFailure" Lib/test/test_httplib.py

Length of output: 1146


Refactor test_local_unknown_cert decorator usage

The test is currently decorated as:

@unittest.expectedFailure
@unittest.skipIf(sys.platform == 'darwin', 'Occasionally success on macOS')
def test_local_unknown_cert(self):
    # The custom cert isn't known to the default trust bundle

This means

  • macOS: test is skipped
  • other platforms: failures are expected (and any passes become “unexpected success” without failing CI)

If the underlying issue is fixed, CI won’t report a green build. To ensure a future pass surfaces as a real success, replace the stacked decorators with a single skipIf (and drop the expectedFailure):

-@unittest.expectedFailure
-@unittest.skipIf(sys.platform == 'darwin', 'Occasionally success on macOS')
+@unittest.skipIf(
+    sys.platform == 'darwin',
+    'Flaky on macOS – see issue ####'
+)
 def test_local_unknown_cert(self):
     # The custom cert isn't known to the default trust bundle
     …

Once the root cause is resolved everywhere, you can remove the skipIf as well.

🧹 Nitpick comments (1)
Lib/test/test_httplib.py (1)

1-1: sys import looks fine but placement is non-alphabetical
Nothing functionally wrong, yet sys ends up as the very first import while other std-lib imports are alphabetically ordered (array, errno, …). If you follow CPython’s own style guides, consider re-ordering to keep import blocks sorted to ‎avoid future merge noise.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b42b57f and 23fc9d9.

📒 Files selected for processing (4)
  • Lib/test/test_dataclasses.py (0 hunks)
  • Lib/test/test_httplib.py (2 hunks)
  • Lib/test/test_reprlib.py (0 hunks)
  • vm/src/stdlib/collections.rs (1 hunks)
💤 Files with no reviewable changes (2)
  • Lib/test/test_reprlib.py
  • Lib/test/test_dataclasses.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • vm/src/stdlib/collections.rs
⏰ Context from checks skipped due to timeout of 90000ms (11)
  • GitHub Check: Run snippets and cpython tests (windows-latest)
  • GitHub Check: Check the WASM package and demo
  • GitHub Check: Run snippets and cpython tests on wasm-wasi
  • GitHub Check: Run snippets and cpython tests (macos-latest)
  • GitHub Check: Run rust tests (windows-latest)
  • GitHub Check: Run rust tests (ubuntu-latest)
  • GitHub Check: Run snippets and cpython tests (ubuntu-latest)
  • GitHub Check: Run tests under miri
  • GitHub Check: Run rust tests (macos-latest)
  • GitHub Check: Check Rust code with rustfmt and clippy
  • GitHub Check: Ensure compilation on various targets

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

🧹 Nitpick comments (4)
vm/src/codecs.rs (1)

408-414: Apply the same “return‐less” pattern to the remaining early exits for stylistic consistency

The newly introduced _ => None branch follows the implicit-return style, but the earlier return Some(Self::UTF_16_NE); (line 406) and return Some(Self::UTF_32_NE); (line 416) still use an explicit return.
Replacing those with plain Some(...) would keep the entire matcher uniform and a bit more idiomatic.

vm/src/stdlib/sys.rs (1)

726-727: Minor style nit: unnecessary :?

threshold is a usize; Debug ({:?}) and Display ({}) output are identical.
Consider plain {threshold} for terser code.

-            let error = format!("maxdigits must be 0 or larger than {threshold:?}");
+            let error = format!("maxdigits must be 0 or larger than {threshold}");
vm/src/exceptions.rs (2)

207-210: Minor consistency nit – mix of formatting styles in the same block

The new inline interpolation (format!(" ({filename})")) is perfectly fine, but two lines above the code still uses the traditional positional style (r##" File "{}", line {}"##).
For readability, consider sticking to one style within the same logical block (or whole file).


212-219: Same consistency point for the source-line write

writeln!(output, " {l_text}")?; adopts the 1.58-style interpolation, while neighbouring statements keep the old style.
Not critical, but aligning on a single convention makes future reviews easier.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 23fc9d9 and 35884dc.

📒 Files selected for processing (21)
  • src/lib.rs (1 hunks)
  • src/shell.rs (1 hunks)
  • stdlib/src/binascii.rs (1 hunks)
  • stdlib/src/csv.rs (2 hunks)
  • vm/src/buffer.rs (2 hunks)
  • vm/src/builtins/complex.rs (1 hunks)
  • vm/src/builtins/object.rs (1 hunks)
  • vm/src/builtins/property.rs (1 hunks)
  • vm/src/builtins/super.rs (2 hunks)
  • vm/src/codecs.rs (2 hunks)
  • vm/src/eval.rs (1 hunks)
  • vm/src/exceptions.rs (3 hunks)
  • vm/src/frame.rs (1 hunks)
  • vm/src/protocol/number.rs (4 hunks)
  • vm/src/stdlib/ctypes/base.rs (1 hunks)
  • vm/src/stdlib/ctypes/function.rs (1 hunks)
  • vm/src/stdlib/ctypes/structure.rs (1 hunks)
  • vm/src/stdlib/io.rs (1 hunks)
  • vm/src/stdlib/posix.rs (2 hunks)
  • vm/src/stdlib/sys.rs (2 hunks)
  • vm/src/vm/compile.rs (1 hunks)
✅ Files skipped from review due to trivial changes (14)
  • vm/src/eval.rs
  • vm/src/stdlib/ctypes/structure.rs
  • src/shell.rs
  • vm/src/vm/compile.rs
  • vm/src/builtins/object.rs
  • vm/src/stdlib/ctypes/base.rs
  • stdlib/src/csv.rs
  • vm/src/protocol/number.rs
  • vm/src/buffer.rs
  • vm/src/frame.rs
  • vm/src/builtins/property.rs
  • src/lib.rs
  • vm/src/stdlib/ctypes/function.rs
  • vm/src/stdlib/posix.rs
⏰ Context from checks skipped due to timeout of 90000ms (11)
  • GitHub Check: Run snippets and cpython tests on wasm-wasi
  • GitHub Check: Run tests under miri
  • GitHub Check: Check the WASM package and demo
  • GitHub Check: Run snippets and cpython tests (windows-latest)
  • GitHub Check: Run snippets and cpython tests (macos-latest)
  • GitHub Check: Run snippets and cpython tests (ubuntu-latest)
  • GitHub Check: Check Rust code with rustfmt and clippy
  • GitHub Check: Run rust tests (windows-latest)
  • GitHub Check: Run rust tests (ubuntu-latest)
  • GitHub Check: Run rust tests (macos-latest)
  • GitHub Check: Ensure compilation on various targets
🔇 Additional comments (8)
vm/src/codecs.rs (1)

1117-1120: LGTM – dropped the superfluous return

The else-branch now just evaluates to Err(bad_err_type(err, vm)), matching the style of the preceding branches. No behavioural change, compilation is unaffected.

stdlib/src/binascii.rs (1)

759-760: LGTM – modernized format string

Using inline {length} is clearer and keeps the message identical at run-time.

vm/src/builtins/complex.rs (1)

69-72: LGTM – warning text refactor

Interpolation via {ret_class} matches Rust ≥ 1.58 idioms and doesn’t change behaviour.
No further issues spotted.

vm/src/stdlib/sys.rs (1)

320-323: Good simplification of error propagation

Inline {e} removes an unnecessary positional argument – no logic change.
Looks fine.

vm/src/builtins/super.rs (2)

1-1: Comment addition is harmless

cspell directive only affects tooling; no runtime impact.


129-131: Clean write-lock assignment simplifies code

Directly overwriting *zelf.inner.write() is clearer and avoids the now-superfluous mem::swap.
No concurrency or safety regressions detected.

vm/src/stdlib/io.rs (1)

1161-1180: Change looks good – direct assignment is clearer than a swap.

Replacing the previous std::mem::swap with

*v = read_buf.take();

makes the intent obvious (restore the taken buffer) and avoids the extra move incurred by swap. Functionality remains identical and consistent with the analogous write-path a few lines above (self.buffer = write_buf.take();).

No further issues spotted in this hunk.

vm/src/exceptions.rs (1)

1614-1619: Double-check Display impls for msg and lineno

format!("{msg} (line {lineno})") relies on PyStrRef implementing Display.
That is currently true, but if this ever changes the compile error will only show up here.
Explicitly converting with .as_str() would make the intent obvious and decouple the code from that impl detail.

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

🧹 Nitpick comments (1)
Lib/test/test_httplib.py (1)

1785-1786: Decorator order & platform match – consider a minor tweak

The stack

@unittest.expectedFailure
@unittest.skipIf(sys.platform == 'darwin', 'Occasionally success on macOS')

works, but it first wraps the function with skipIf, then with expectedFailure.
For clarity (and to avoid the double-wrapper calling an expectedFailure wrapper that never actually runs on macOS), it’s slightly cleaner to put skipIf outermost:

-@unittest.expectedFailure
-@unittest.skipIf(sys.platform == 'darwin', 'Occasionally success on macOS')
+@unittest.skipIf(sys.platform == 'darwin', 'Occasionally success on macOS')
+@unittest.expectedFailure

Result:
• On macOS the test is skipped immediately.
• On other platforms the test still registers as an expected failure.

Purely cosmetic – behaviour is unchanged, so feel free to ignore if you prefer the current order.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 35884dc and c43b9fa.

📒 Files selected for processing (4)
  • Lib/test/test_dataclasses.py (0 hunks)
  • Lib/test/test_httplib.py (2 hunks)
  • Lib/test/test_reprlib.py (0 hunks)
  • vm/src/stdlib/collections.rs (1 hunks)
💤 Files with no reviewable changes (2)
  • Lib/test/test_reprlib.py
  • Lib/test/test_dataclasses.py
✅ Files skipped from review due to trivial changes (1)
  • vm/src/stdlib/collections.rs
⏰ Context from checks skipped due to timeout of 90000ms (11)
  • GitHub Check: Run snippets and cpython tests (ubuntu-latest)
  • GitHub Check: Run tests under miri
  • GitHub Check: Run snippets and cpython tests (windows-latest)
  • GitHub Check: Run snippets and cpython tests on wasm-wasi
  • GitHub Check: Run snippets and cpython tests (macos-latest)
  • GitHub Check: Check the WASM package and demo
  • GitHub Check: Run rust tests (macos-latest)
  • GitHub Check: Run rust tests (windows-latest)
  • GitHub Check: Run rust tests (ubuntu-latest)
  • GitHub Check: Check Rust code with rustfmt and clippy
  • GitHub Check: Ensure compilation on various targets
🔇 Additional comments (1)
Lib/test/test_httplib.py (1)

1-1: sys import added in isolation looks fine

The extra import sys is required for the new @unittest.skipIf() condition and does not clash with any other symbols in this file.

@youknowone youknowone merged commit a6dd2d8 into RustPython:main Jun 15, 2025
11 of 12 checks passed
@youknowone youknowone deleted the fix-deque branch June 15, 2025 07:04
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.

1 participant