Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] importing "Litestar" somehow makes "Faker" Not Random anymore #1889

Closed
saltcable opened this issue Jul 13, 2023 · 7 comments
Closed

[Bug] importing "Litestar" somehow makes "Faker" Not Random anymore #1889

saltcable opened this issue Jul 13, 2023 · 7 comments

Comments

@saltcable
Copy link

  • Faker version: 19.1.0
  • Litestar version: 2.0.0b2
  • OS: Python 3.10.5 (tags/v3.10.5:f377153, Jun 6 2022, 16:14:13) [MSC v.1929 64 bit (AMD64)] on win32

Faker is working fine but when Litestar is imported, it's not random anymore. Same result/output every time.

Steps to reproduce

  1. code (lab.py)
import faker
import litestar  # <<=== the problem

fake = faker.Faker()
print(fake.md5())
  1. run few time
python lab.py
python lab.py
python lab.py

Expected behavior (by removing import litestar)

Random output all the time
7442b46046a7c2d7ca080483a0d45ad4
a87b76986a9afbb9da63dde9ed4d2495
6924bc922dd1db07440ec3298c42afb8

Actual behavior (same environment)

Same every time. for all the functions
9fc4f6348d3311fa3376be5aa395877a
9fc4f6348d3311fa3376be5aa395877a
9fc4f6348d3311fa3376be5aa395877a

@saltcable
Copy link
Author

@stefan6419846
Copy link
Contributor

Given the litestar maintainer comment in the linked issue, what would be your desired solution for faker? I do not see faker ensuring compatibility with each third-party package which might "mess" with the seeding automatically.

@provinzkraut
Copy link

Given the litestar maintainer comment in the linked issue, what would be your desired solution for faker? I do not see faker ensuring compatibility with each third-party package which might "mess" with the seeding automatically.

This is indeed not an issue on your end but ours!

@Goldziher
Copy link

well, no exactly. The issue is that faker only allows global configuration - rather than a per Faker() instance configuration of randomness.

When we seed random we do random.Random rather than the global randomness.

@fcurella
Copy link
Collaborator

The issue is that faker only allows global configuration

Is Faker.seed_instance() not working?

@Goldziher
Copy link

The issue is that faker only allows global configuration

Is Faker.seed_instance() not working?

Lol, I was sure this is depracted. Lemme test

@saltcable
Copy link
Author

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

No branches or pull requests

5 participants