Skip to content

Feature/userlistsrequest add optional rfc#369

Merged
pachCode merged 5 commits intomainfrom
feature/userlistsrequest-add-optional-rfc
Mar 3, 2025
Merged

Feature/userlistsrequest add optional rfc#369
pachCode merged 5 commits intomainfrom
feature/userlistsrequest-add-optional-rfc

Conversation

@gmorales96
Copy link
Copy Markdown
Contributor

@gmorales96 gmorales96 commented Feb 26, 2025

Description

This PR update the UserListsRequest model by adding an optional rfc field. This change is necessary because the new QEQ API supports searching by RFC.

Changes

  • Added rfc: Optional[Rfc] to the UserListsRequest model.
  • Added tests to validate the updated UserListsRequest model.

Summary by CodeRabbit

  • New Features

    • Introduced an optional RFC field to enhance user request validation, ensuring at least one required field is present.
    • Added a new type alias for non-empty string validation to improve data integrity.
  • Chores

    • Updated the version to 2.1.3 to reflect the latest improvements.
  • Tests

    • Expanded test coverage with parameterized cases that verify both valid and invalid input scenarios for improved reliability.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Feb 26, 2025

Walkthrough

The changes introduce a new optional field rfc to the UserListsRequest class and update the check_request method to ensure that at least one of curp, account_number, rfc, or has_name is present. The names, first_surname, and second_surname fields have been modified to use NonEmptyStr, enforcing a non-empty string requirement. The version number in the version.py file has been updated from '2.1.2' to '2.1.3'. In the testing suite, the previous test_user_lists_request function has been removed and replaced with two new parameterized test functions: test_user_lists_request_valid_params, which checks valid input combinations, and test_user_lists_request_invalid_params, which verifies that a ValueError is raised for invalid input scenarios. Additionally, a new type alias NonEmptyStr has been introduced to enforce non-empty string values.


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 8a17f19 and 8073a48.

📒 Files selected for processing (2)
  • cuenca_validations/types/general.py (1 hunks)
  • cuenca_validations/types/requests.py (3 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
`**/*.py`: Enforce Relative Imports for Internal Modules

En...

**/*.py: Enforce Relative Imports for Internal Modules

Ensure that any imports referencing internal modules use relative paths. However, if modules reside in the main module directories (for example /src or /library_or_app_name) —and relative imports are not feasible—absolute imports are acceptable. Additionally, if a module is located outside the main module structure (for example, in /tests or /scripts at a similar level), absolute imports are also valid.

Examples and Guidelines:

  1. If a module is in the same folder or a subfolder of the current file, use relative imports. For instance: from .some_module import SomeClass
  2. If the module is located under /src or /library_or_app_name and cannot be imported relatively, absolute imports are allowed (e.g., from library_or_app_name.utilities import helper_method).
  3. If a module is outside the main module directories (for example, in /tests, /scripts, or any similarly placed directory), absolute imports are valid.
  4. External (third-party) libraries should be imported absolutely (e.g., import requests).
  • cuenca_validations/types/general.py
  • cuenca_validations/types/requests.py
`**/*.py`: Rule: Enforce Snake Case in Python Backend
  1. N...

**/*.py:
Rule: Enforce Snake Case in Python Backend

  1. New or Modified Code: Use snake_case for all variables, functions, methods, and class attributes.
  2. Exceptions (Pydantic models for API responses):
    • Primary fields must be snake_case.
    • If older clients expect camelCase, create a computed or alias field that references the snake_case field.
    • Mark any camelCase fields as deprecated or transitional.

Examples

Invalid:

class CardConfiguration(BaseModel):
    title: str
    subTitle: str  # ❌ Modified or new field in camelCase

Valid:

class CardConfiguration(BaseModel):
    title: str
    subtitle: str  # ✅ snake_case for new/modified field

    @computed_field
    def subTitle(self) -> str:  # camelCase allowed only for compatibility
        return self.subtitle

Any direct use of camelCase in new or updated code outside of these exceptions should be flagged.

  • cuenca_validations/types/general.py
  • cuenca_validations/types/requests.py
🔇 Additional comments (7)
cuenca_validations/types/general.py (1)

25-27: Well-defined type alias for string validation.

The new NonEmptyStr type alias effectively enforces non-empty strings by combining whitespace stripping and minimum length constraints. This provides a reusable type that can be used throughout the codebase for consistent validation.

cuenca_validations/types/requests.py (6)

58-58: Correct import of the new NonEmptyStr type.

The import statement properly references the newly created type from the general module.


635-635: Successfully added RFC as an optional search parameter.

The addition of the optional rfc field to the UserListsRequest model properly implements the PR's objective to support the new QEQ API feature for searching by RFC.


639-647: Correctly implemented string field constraints as requested.

The string fields have been updated to use the NonEmptyStr type, which addresses the previous review comment requesting min_length=1 and strip_white_spaces=True on these fields.


652-664: Enhanced field validation logic for name-related fields.

The updated validation logic ensures proper relationships between the name-related fields:

  1. names is required when either first_surname or second_surname is provided
  2. first_surname is required when names is provided

This validation ensures that the name fields are provided in a meaningful and complete manner.


665-672: Updated validation to include RFC in parameter requirements.

The validation logic has been appropriately expanded to include rfc in the list of parameters where at least one must be provided, maintaining the requirement that a search must have at least one filter criterion.


680-680: Example updated with RFC value.

The example in the schema documentation has been correctly updated to include a sample RFC value, which helps API users understand the expected format.

✨ Finishing Touches
  • 📝 Generate Docstrings

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.
  • @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.

@codecov
Copy link
Copy Markdown

codecov bot commented Feb 26, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (70f4fcb) to head (8073a48).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #369   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           16        16           
  Lines         1289      1295    +6     
=========================================
+ Hits          1289      1295    +6     
Flag Coverage Δ
unittests 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
cuenca_validations/types/general.py 100.00% <100.00%> (ø)
cuenca_validations/types/requests.py 100.00% <100.00%> (ø)
cuenca_validations/version.py 100.00% <100.00%> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 70f4fcb...8073a48. Read the comment docs.

@gmorales96 gmorales96 requested a review from felipao-mx March 3, 2025 17:52
@gmorales96 gmorales96 requested a review from felipao-mx March 3, 2025 18:17
@pachCode pachCode merged commit 22207bb into main Mar 3, 2025
20 checks passed
@pachCode pachCode deleted the feature/userlistsrequest-add-optional-rfc branch March 3, 2025 20:13
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.

3 participants