Skip to content

Fix regressions from 6.0 #3

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 4 commits into from
Jun 12, 2025
Merged

Fix regressions from 6.0 #3

merged 4 commits into from
Jun 12, 2025

Conversation

digizeph
Copy link
Member

This pull request includes updates to the pybgpkit-parser library to enhance serialization capabilities, improve Python code style, and refine method signatures. Key changes include adding serde for serialization, modifying Python code for better readability, and updating method definitions to support additional parameters.

Method Signature Refinements:

  • src/lib.rs: Updated the Parser constructor to make cache_dirand filters as optional parameters.

Serialization Enhancements:

  • Cargo.toml: Added serde and serde_json dependencies to enable serialization functionality.
  • src/lib.rs: Updated Elem struct to derive the Serialize trait for JSON serialization.
  • src/lib.rs: Added str_repr method to provide a string representation of Elem using JSON serialization.

Python Code Example Improvements:

  • examples/filter_count_print.py: Replaced == None with is None for better Python style and readability. Removed indentation in JSON dumps for compact output.

@digizeph digizeph self-assigned this Jun 12, 2025
@Copilot Copilot AI review requested due to automatic review settings June 12, 2025 17:16
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes regressions in the pybgpkit-parser library by enhancing serialization capabilities, improving Python style, and refining method signatures.

  • Updated Rust code to support JSON serialization via serde.
  • Enhanced Python examples for better idiomatic style and output compactness.
  • Revised the Parser constructor to make the cache_dir and filters optional.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/lib.rs Added serde::Serialize for Elem, introduced str for JSON serialization, updated Parser constructor signature.
examples/filter_count_print.py Improved Python style by replacing equality checks with identity comparisons and compacting JSON output.
Cargo.toml Included serde and serde_json dependencies for serialization support.
Comments suppressed due to low confidence (1)

src/lib.rs:107

  • Using unwrap in the str method can cause a runtime panic if serialization fails. Consider propagating the error using the '?' operator or mapping it to a PyErr to improve error handling.
Ok(format("{}", serde_json::to_string(self).unwrap()))

@digizeph digizeph merged commit ffa93ae into main Jun 12, 2025
1 check passed
@digizeph digizeph deleted the fix-regression branch June 12, 2025 17:22
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