Skip to content

feat: pure-Rust faker2 — Python binder + 151-locale engine + algorithmic formatters - #13

Merged
jqueguiner merged 5 commits into
masterfrom
feat/faker2-pure-rust
Jul 15, 2026
Merged

jqueguiner merged 5 commits into
masterfrom
feat/faker2-pure-rust

Conversation

@jqueguiner

Copy link
Copy Markdown
Owner

Makes the faker2 PyPI package a pure-Rust engine with a thin Python binder (PyO3), and ports the bulk of faker to Rust via two sub-agent waves.

What landed

  • Pure-Rust faker2 package (native/): import faker2 loads the compiled Rust core (faker2._native). Self-contained wheels (dataset bundled), sdist, trusted publishing.
  • 151-locale generic engine (rust/src/locale.rs, feature locales): data-driven formatters via a declarative recipe map (extracted by 26 agents) + per-locale dataset. Faker.gen(locale, formatter).
  • ~140 algorithmic formatters (rust/src/providers/algo/, 15 providers via 16 agents): Luhn cards, EAN/UPC/JAN + VIN checksums, IBAN mod-97/BBAN/ABA/SWIFT, uuid/md5/sha/password, ipv4/6/mac/url/email/dga, hex/rgb/hsl colors, catch_phrase/bs, date_time (civil-from-days), pyint/pyfloat, currency, files, isbn/sbn, msisdn.

Verified

  • Checksums independently tested: Luhn, EAN-13 mod-10, IBAN mod-97 all pass (tests/algo.rs).
  • Coverage/151: name 150, job 151, company 146, city 145, phone 141.
  • rust-ci: fmt + clippy -D warnings + tests now cover default / real-names / locales.

Scope / remaining

  • A few binary/collection formatters (pylist/json/image-bytes) intentionally skipped.
  • ssn/passport per-locale checksums partial.
  • Version bump + retiring the pure-Python publish workflow needed before an actual PyPI release.

🤖 Generated with Claude Code

jqueguiner and others added 5 commits July 15, 2026 20:33
Repackage native/ so the PyPI distribution and import module are both `faker2`:
a thin Python binder (native/python/faker2/__init__.py) over the compiled Rust
core `faker2._native`. `import faker2` runs the Rust engine; no fake-data logic
in Python.

- pyproject: name=faker2, version 40.28.1.post1, module-name faker2._native,
  dataset bundled into the wheel.
- wheels.yml: build faker2 wheels (Linux x86_64/aarch64, macOS Intel/ARM,
  Windows) + an sdist, attach to the Release and publish to PyPI via trusted
  publishing (project faker2, workflow wheels.yml, environment pypi).

Scope: the Rust core is en_US providers + 139-country name intelligence today;
locales port into the core over time. Publishing this supersedes the
pure-Python faker2 distribution — bump the version and retire the pure-Python
publish workflow before releasing.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… locales

Port all data-driven faker2 formatters to Rust via a declarative recipe map
(built by fanning out one sub-agent per provider) interpreted against the
extracted per-locale dataset:

- data/locales.json: every locale's provider data (151 locales, ~20 providers).
- data/recipes.json: 230 formatters classified CHOICE/FORMAT/NUMERIFY/BOTHIFY/
  CONSTANT/ALGORITHMIC by the agents.
- rust/src/locale.rs (feature `locales`): Faker::gen(locale, formatter) resolves
  recipes + a field-name fallback for locale-subclass tokens (gendered names,
  city_name, company_prefix, ...) and a {{token}} template expander.

Coverage across 151 locales: name 150/151, job 151, company 146, city 145,
phone_number 141, address 47. Exposed on the pure-Rust `faker2` package:
faker2.Faker.gen(locale, name), faker2.locales() (151), faker2.locale_formatters().

The 193 ALGORITHMIC formatters (checksums, dates, Luhn, ...) are the remaining
port work, done in further agent waves.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…, ...)

Second sub-agent wave: 15 providers' ALGORITHMIC formatters implemented in Rust
under providers/algo/, dispatched from Faker::gen. ~140 formatters now work in
pure Rust, e.g.:
- credit_card_number (Luhn), ean8/13 + upc + jan (GS1 checksums), vin
- iban (ISO 7064 mod-97), bban, aba, swift; barcode checksums
- uuid4/1/7, md5/sha hex, password, ipv4/ipv6/mac, url, email, dga
- hex/rgb/hsl colors (RandomColor HSV), catch_phrase/bs joins
- credit_card_expire + date_time via civil-from-days (no date crate)
- pyint/pybool/pyfloat, file names/paths, isbn/sbn, msisdn

Each provider is a self-contained algo/<provider>.rs with a `dispatch` fn;
gen() falls through data-driven -> algorithmic. rust-ci now lints+tests the
`locales` feature too. (currency stub pending; a few binary/collection
formatters intentionally skipped.)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- currency.rs: currency/currency_code/currency_name, cryptocurrency_*, pricetag
  (currency + crypto tables hardcoded from the Python base provider).
- tests/algo.rs: independently verify the ported checksums — credit_card_number
  passes Luhn, ean13 passes GS1 mod-10, iban passes ISO 7064 mod-97, plus
  currency/uuid shape checks. All green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jqueguiner
jqueguiner merged commit 5f04d58 into master Jul 15, 2026
19 checks passed
@jqueguiner
jqueguiner deleted the feat/faker2-pure-rust branch July 15, 2026 21:06
@codecov-commenter

codecov-commenter commented Jul 15, 2026 •

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.40%. Comparing base (c450c3d) to head (6fa4cd8).
⚠️ Report is 1 commits behind head on master.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #13      +/-   ##
==========================================
- Coverage   96.43%   96.40%   -0.03%     
==========================================
  Files         838      838              
  Lines       12608    12608              
==========================================
- Hits        12158    12155       -3     
- Misses        450      453       +3     
Flag Coverage Δ
ubuntu-3.10 96.35% <ø> (+<0.01%) ⬆️
ubuntu-3.11 96.35% <ø> (-0.02%) ⬇️
ubuntu-3.12 96.36% <ø> (+0.03%) ⬆️
ubuntu-3.13 96.35% <ø> (+<0.01%) ⬆️
ubuntu-3.14 94.86% <ø> (ø)
ubuntu-3.15 94.88% <ø> (+0.03%) ⬆️
ubuntu-pypy-3.11 94.87% <ø> (-0.01%) ⬇️

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

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

2 participants