Skip to content

Conversation

@felipao-mx
Copy link
Member

@felipao-mx felipao-mx commented Jul 1, 2025

actualiza banks.py

Summary by CodeRabbit

  • Documentation
    • Improved README formatting and added a new section with instructions for keeping the list of participants updated.
  • Bug Fixes
    • Updated the name for bank code '90715' to "Cashi Cuenta".
  • Chores
    • Bumped version number to 2.1.4.

@coderabbitai
Copy link

coderabbitai bot commented Jul 1, 2025

Walkthrough

This change updates the README.md file to correct a minor heading formatting issue and adds a new section describing the use of the compare_banks.py script for synchronizing the local list of SPEI participants with Banxico's official data. It also updates the bank name for code '90715' in the BANK_NAMES dictionary from "Cartera Digital" to "Cashi Cuenta" in clabe/banks.py. Additionally, the version number in clabe/version.py is incremented from '2.1.3' to '2.1.4'.

Possibly related PRs

  • Add walmart #174: Updates the bank name for code '90715' in BANK_NAMES, directly relating to the same dictionary entry modified in this PR.
  • Update banks #176: Introduces the compare_banks.py script and updates bank lists, which is referenced and documented in the README changes of this PR.
  • Update banks #177: Modifies multiple bank name mappings in BANK_NAMES, showing a pattern of similar updates to the bank dictionary as in this PR.

Suggested reviewers

  • pachCode
✨ 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.

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 (3)
clabe/banks.py (1)

127-133: Alphabetical-order invariant still respected – consider automating the check
'Cashi Cuenta' correctly slots between 'Caja Pop Mexica' and 'CB Intercam', so the manual edit preserves the “alphabetical by bank name” rule stated in the comment.

To avoid human error for future edits, a tiny pytest asserting alphabetical order would be useful:

def test_bank_names_alphabetical():
    names = list(BANK_NAMES.values())
    assert names == sorted(names, key=str.casefold)
README.md (2)

125-129: Add the missing comma before “pero”
Spanish style guides require a comma before the conjunction “pero”.

-**Nuevos participantes**: Instituciones que aparecen en Banxico pero no están en el paquete
+**Nuevos participantes**: Instituciones que aparecen en Banxico, pero no están en el paquete

140-144: Minor punctuation tweak
For parallelism, add a period at the end of the last bullet.

-**CHANGES**: Cambios de nombre que requieren actualización
+**CHANGES**: Cambios de nombre que requieren actualización.
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 31ce660 and 8ccf99a.

📒 Files selected for processing (3)
  • README.md (2 hunks)
  • clabe/banks.py (1 hunks)
  • clabe/version.py (1 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
`**/*.py`: Enforce Relative Imports for Internal Modules

Ensure that any import...

**/*.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).

⚙️ Source: CodeRabbit Configuration File

List of files the instruction was applied to:

  • clabe/version.py
  • clabe/banks.py
`**/*.py`: Rule: Enforce Snake Case in Python Backend
  1. New or Modified Code:...

**/*.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.

⚙️ Source: CodeRabbit Configuration File

List of files the instruction was applied to:

  • clabe/version.py
  • clabe/banks.py
`**/*.py`: Use try/except for concise error handling when accessing nested dicti...

**/*.py: Use try/except for concise error handling when accessing nested dictionary keys:

try:
    can_ignore_error = data['error']['code'] in ignore_error_codes
except KeyError:
    can_ignore_error = False

❌ Avoid Verbose Chained Conditionals:

can_ignore_error = (
    'code' in data['error']
    and data['error']['code'] in ignore_error_codes
)

Explanation:
The try/except approach:

Reduces code complexity and nesting
Improves readability by focusing on the "happy path" logic
Follows Python's "easier to ask forgiveness than permission" (EAFP) idiom

Severity: Important (Not a Nitpick)
This pattern significantly improves code maintainability and readability, especially as dictionary access patterns become more complex.

⚙️ Source: CodeRabbit Configuration File

List of files the instruction was applied to:

  • clabe/version.py
  • clabe/banks.py
`**/*.py`: Context Agave is our internal Python library for processing SQS messa...

**/*.py: Context
Agave is our internal Python library for processing SQS messages. The @task decorator can automatically convert JSON to Pydantic models.

Rule
Always annotate @task parameters with Pydantic models instead of manually converting dictionaries.

Correct Pattern

from pydantic import BaseModel
from agave.tasks.sqs_tasks import task

class User(BaseModel):
    name: str
    age: int
    
@task(queue_url=QUEUE_URL, region_name='us-east-1')
async def task_validator(message: User) -> None:
    # The message is already a User instance - no conversion needed
    print(message.name)  # Direct attribute access

Incorrect Pattern

from pydantic import BaseModel
from agave.tasks.sqs_tasks import task

class User(BaseModel):
    name: str
    age: int
    
@task(queue_url=QUEUE_URL, region_name='us-east-1')
async def task_validator(message_data: dict) -> None:  # or unannotated parameter
    # Unnecessary conversion
    message = User(**message_data)
    print(message.name)

Explanation
The Agave @task decorator automatically:

  • Reads JSON messages from SQS queues
  • Converts them to Pydantic model instances when the handler parameter is annotated
  • Performs validation based on the Pydantic model

⚙️ Source: CodeRabbit Configuration File

List of files the instruction was applied to:

  • clabe/version.py
  • clabe/banks.py
`**/*.py`: ## MANDATORY: Use built-in Pydantic validators

Description

Avoid...

**/*.py: ## MANDATORY: Use built-in Pydantic validators

Description

Avoid creating custom validators that duplicate functionality already provided by Pydantic's built-in validators, pydantic_extra_types package, or third-party Pydantic validator libraries. This improves code maintainability and reduces unnecessary unit tests.

Bad Practice

from pydantic import BaseModel, field_validator

class MyValidator(BaseModel):
    location: str
    
    @field_validator('location')
    def validate_location(cls, value: str) -> str:
        values = value.split(',')
        if len(values) != 3:
            raise ValueError('Must provide exactly 3 values for location')
        # Custom validation logic that duplicates functionality
        return value

Good Practice

from pydantic import BaseModel
from pydantic_extra_types.coordinate import Coordinate

class MyValidator(BaseModel):
    location: Coordinate

Unit Test Guidelines

Do not write unit tests specifically for validating the behavior of Pydantic's built-in validators. These are already well-tested by the Pydantic library itself.

Tests to Remove

def test_invalid_location():
    pytest.raises(ValidationError):
        MyValidator(location='foo,bar')

Rule Enforcement

This is a mandatory rule, not a refactoring suggestion. Changes must be implemented when:

  1. A custom validator replicates functionality already available in Pydantic's ecosystem
  2. There is a suitable built-in, pydantic_extra_types, or third-party Pydantic validator available

Actions required:

  1. Replace custom validators with appropriate existing validators
  2. Remove unnecessary unit tests that only validate built-in Pydantic validation behavior
  3. Block PRs that introduce new custom validators when alternatives exist

⚙️ Source: CodeRabbit Configuration File

List of files the instruction was applied to:

  • clabe/version.py
  • clabe/banks.py
🪛 LanguageTool
README.md

[uncategorized] ~125-~125: En la mayoría de los casos la conjunción ‘pero’ va precedida de una coma.
Context: ...*: Instituciones que aparecen en Banxico pero no están en el paquete - **Bajas de par...

(COMMA_PERO)


[uncategorized] ~125-~125: Probablemente hay un error. Considere aplicar la sugerencia.
Context: ...n en Banxico pero no están en el paquete - Bajas de participantes: Instituciones ...

(AI_ES_GGEC_REPLACEMENT_OTHER)


[uncategorized] ~126-~126: Probablemente hay un error. Considere aplicar la sugerencia.
Context: ... aparecen en la lista oficial de Banxico - Cambios de nombre: Participantes que m...

(AI_ES_GGEC_REPLACEMENT_OTHER)


[uncategorized] ~127-~127: En la mayoría de los casos la conjunción ‘pero’ va precedida de una coma.
Context: ...ticipantes que mantienen el mismo código pero han cambiado su nombre Para ejecutar l...

(COMMA_PERO)


[uncategorized] ~138-~138: Probablemente hay un error. Considere aplicar la sugerencia.
Context: ... reporte con las diferencias encontradas: - ADDITIONS: Nuevos participantes ...

(AI_ES_GGEC_REPLACEMENT_PUNCTUATION)


[uncategorized] ~141-~141: Probablemente hay un error. Considere aplicar la sugerencia.
Context: ...deben eliminarse por ya no estar activos - CHANGES: Cambios de nombre que requier...

(AI_ES_GGEC_REPLACEMENT_OTHER)

🔇 Additional comments (2)
clabe/version.py (1)

1-1: Version bump looks correct
Nothing else changed in this file; the new string '2.1.4' matches the PR scope.

clabe/banks.py (1)

85-90: Sync key map vs. name change
The key '715''90715' in BANKS is unchanged, while only the display name was updated. That’s expected, but double-check any downstream code that might have cached the old string "Cartera Digital".

@felipao-mx felipao-mx merged commit a01d62f into main Jul 3, 2025
15 checks passed
@felipao-mx felipao-mx deleted the update-banks branch July 3, 2025 23:53
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