Conversation
📝 WalkthroughWalkthroughThis PR introduces comprehensive Pydantic data models for CFDI 4.0 "Carta Porte" (Bill of Lading) functionality through a new module, exposes these models via package-level imports, updates the InvoiceComplement to reference the correct alias, and increments the package version. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
fiscalapi/__init__.py (1)
92-92:⚠️ Potential issue | 🟡 MinorDuplicate import:
LadingComplementis already imported frombill_of_lading_modelsat line 45.🧹 Proposed fix: Remove duplicate import
PayrollDeduction, PayrollDisability, PayrollComplement, - LadingComplement, InvoiceComplement,🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@fiscalapi/__init__.py` at line 92, Remove the duplicate import of LadingComplement from bill_of_lading_models: locate the second occurrence of "LadingComplement" in the import list (the one referenced in the diff) and delete it so only the original import (already present around the earlier import block) remains; ensure no other symbols or commas are accidentally removed when editing the import list.fiscalapi/models/__init__.py (1)
77-77:⚠️ Potential issue | 🟡 MinorDuplicate import:
LadingComplementis already imported frombill_of_lading_modelsat line 32.Since
fiscalapi_modelsimportsLadingComplementfrombill_of_lading_modelsand re-exports it, this import is redundant.🧹 Proposed fix: Remove duplicate import
PayrollDeduction, PayrollDisability, PayrollComplement, - LadingComplement, InvoiceComplement,🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@fiscalapi/models/__init__.py` at line 77, Remove the duplicate import of LadingComplement (already imported from bill_of_lading_models earlier) by deleting the redundant "LadingComplement" entry in the import/export list so that LadingComplement is only imported/re-exported once; ensure the remaining import from bill_of_lading_models (the original LadingComplement reference) is kept and run tests/type checks to verify no other duplicate entries remain.
🧹 Nitpick comments (1)
fiscalapi/models/fiscalapi_models.py (1)
531-531: Consider consistency:LadingComplementextendsBaseModelwhile sibling complements extendBaseDto.All complement types in
InvoiceComplement(LocalTaxesComplement,PaymentComplement,PayrollComplement) inherit fromBaseDto, which providesid,created_at, andupdated_atfields.LadingComplementextendsBaseModeldirectly, creating a structural inconsistency.If the Carta Porte API doesn't return those base fields, this is intentional and acceptable. Otherwise, align
LadingComplementto extendBaseDtofor consistency.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@fiscalapi/models/fiscalapi_models.py` at line 531, The LadingComplement type currently extends BaseModel while its sibling complements used in InvoiceComplement (e.g., LocalTaxesComplement, PaymentComplement, PayrollComplement) extend BaseDto; update LadingComplement to inherit from BaseDto instead of BaseModel so it includes the common id/created_at/updated_at fields and matches the structure of other complements (change the class signature for LadingComplement to extend BaseDto and adjust any imports/refs accordingly), unless the Carta Porte API definitively does not return those base fields — in that case add a clarifying comment explaining the intentional omission.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@fiscalapi/__init__.py`:
- Line 196: The __all__ list in fiscalapi.__init__ contains a duplicate export
"LadingComplement"; remove the redundant "LadingComplement" entry so each public
symbol appears only once—update the __all__ definition where "LadingComplement"
is listed (ensure the remaining single occurrence stays) to eliminate the
duplicate export.
In `@fiscalapi/models/__init__.py`:
- Line 136: The __all__ list in fiscalapi.models contains a duplicated export
name "LadingComplement"; locate the __all__ definition in models/__init__.py and
remove the redundant "LadingComplement" entry so each exported symbol appears
only once (keep one "LadingComplement" and ensure the list remains syntactically
valid).
---
Outside diff comments:
In `@fiscalapi/__init__.py`:
- Line 92: Remove the duplicate import of LadingComplement from
bill_of_lading_models: locate the second occurrence of "LadingComplement" in the
import list (the one referenced in the diff) and delete it so only the original
import (already present around the earlier import block) remains; ensure no
other symbols or commas are accidentally removed when editing the import list.
In `@fiscalapi/models/__init__.py`:
- Line 77: Remove the duplicate import of LadingComplement (already imported
from bill_of_lading_models earlier) by deleting the redundant "LadingComplement"
entry in the import/export list so that LadingComplement is only
imported/re-exported once; ensure the remaining import from
bill_of_lading_models (the original LadingComplement reference) is kept and run
tests/type checks to verify no other duplicate entries remain.
---
Nitpick comments:
In `@fiscalapi/models/fiscalapi_models.py`:
- Line 531: The LadingComplement type currently extends BaseModel while its
sibling complements used in InvoiceComplement (e.g., LocalTaxesComplement,
PaymentComplement, PayrollComplement) extend BaseDto; update LadingComplement to
inherit from BaseDto instead of BaseModel so it includes the common
id/created_at/updated_at fields and matches the structure of other complements
(change the class signature for LadingComplement to extend BaseDto and adjust
any imports/refs accordingly), unless the Carta Porte API definitively does not
return those base fields — in that case add a clarifying comment explaining the
intentional omission.
🪄 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: defaults
Review profile: CHILL
Plan: Pro
Run ID: 59d998d3-3e3a-4e77-bbd7-be5e3fec2675
📒 Files selected for processing (7)
examples/ejemplos-factura-carta-porte-referencias.pyexamples/ejemplos-factura-carta-porte-valores.pyfiscalapi/__init__.pyfiscalapi/models/__init__.pyfiscalapi/models/bill_of_lading_models.pyfiscalapi/models/fiscalapi_models.pysetup.py
| @@ -171,6 +195,27 @@ | |||
| "PayrollComplement", | |||
| "LadingComplement", | |||
There was a problem hiding this comment.
Duplicate entry: "LadingComplement" appears twice in __all__ (lines 196 and 218).
🧹 Proposed fix: Remove duplicate from line 218
"TipoFigura",
- "LadingComplement",
# Invoice modelsAlso applies to: 218-218
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@fiscalapi/__init__.py` at line 196, The __all__ list in fiscalapi.__init__
contains a duplicate export "LadingComplement"; remove the redundant
"LadingComplement" entry so each public symbol appears only once—update the
__all__ definition where "LadingComplement" is listed (ensure the remaining
single occurrence stays) to eliminate the duplicate export.
| "TransporteFerroviario", | ||
| "ParteTransporte", | ||
| "TipoFigura", | ||
| "LadingComplement", |
There was a problem hiding this comment.
Duplicate entry: "LadingComplement" appears twice in __all__ (lines 136 and 184).
Remove one of the duplicate entries.
🧹 Proposed fix: Remove duplicate from line 184
"PayrollComplement",
- "LadingComplement",
"InvoiceComplement",Also applies to: 184-184
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@fiscalapi/models/__init__.py` at line 136, The __all__ list in
fiscalapi.models contains a duplicated export name "LadingComplement"; locate
the __all__ definition in models/__init__.py and remove the redundant
"LadingComplement" entry so each exported symbol appears only once (keep one
"LadingComplement" and ensure the list remains syntactically valid).
Summary by CodeRabbit
New Features
Chores