Skip to content

Conversation

@jasur-py
Copy link
Contributor

What does this change

Fixed Brazilian ISBN locale support (issue #2216)

What was wrong

When user was using Faker('pt_BR'), the isbn10() and isbn13() methods were generating ISBNs with group codes like 0 or 1 (which are the US/UK regions) instead of the Brazilian group code 85, absolutely ignoring the configured locale.

How this fixes it

  1. Added Brazilian ISBN provider (faker/providers/isbn/pt_BR/__init__.py) with group code 85.
  2. Followed the same patterns as other localised ISBN providers (es_ES, en_US).
  3. Ensured Faker('pt_BR') generating ISBN's with Brazilian group prefix.

Fixes #...

  • New file: faker/providers/isbn/pt_BR/__init__.py -> Brazilian ISBN provider.
  • Updated file: tests/providers/test_isbn.py -> Added detailed test for Brazilian ISBN generation.

Tests:
All tests passed, new tests verified, followed black & flake & mypy.

  • Before was: 0-9720769-8-0 (US/UK)
  • Now: 85-3225-314-8 (Brazilian 85)
Screenshot 2025-06-20 at 7 10 05 AM Screenshot 2025-06-20 at 7 15 03 AM

Checklist

  • I have read the documentation about CONTRIBUTING
  • I have read the documentation about Coding style
  • I have run make lint

- Added new DOI provider with correct implementation
- Removed incorrect DOI implementation from Spanish locale
- Added tests for DOI provider
- Updated CHANGELOG.md
- Added Brazilian ISBN provider with group code 85
- Ensured Faker('pt_BR') generating ISBNs with Brazilian group prefix
- Added tests to verify Brazilian ISBN generation
- Fixed the issue where pt_BR locale ignored locale and generated international ISBNs
@jasur-py
Copy link
Contributor Author

Thank you in advance for review ❤️

Format: 10.{4-9 digits}/{alphanumeric string}
Eg: 10.1000/xyz123
fix/brazilian-isbn-locale
Copy link
Collaborator

Choose a reason for hiding this comment

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

could you remove those lines?

- Updated documentation to clarify new format (AA-999-AA) since 2009
- Added specific methods for new and old format license plates
- Added comprehensive tests for both formats
- New format is properly prioritized
@fcurella
Copy link
Collaborator

The PR contains changes that have nothing to do with the ISBN provider (eg I see some changes to the automotive one).

Could you please clean up your branch to contain only changes to faker/providers/isbn/pt_BR/__init__.py + tests for it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants