joke2k / faker

Faker is a Python package that generates fake data for you.
https://faker.readthedocs.io
MIT License
17.74k stars 1.93k forks source link

Tab completion in shell not working since Python 3.9 #1805

Closed CelestialGuru closed 1 year ago

CelestialGuru commented 1 year ago

Setup:

# pip install faker=="17.3.0"
# python
>>> import faker
>>> fake = faker.Faker()
>>> fake.

Now type [TAB] once or twice.

If you are using Python 3.8, you will see:

Display all 280 possibilities? (y or n)
fake.aba(                             fake.generator_attrs                  fake.pyfloat(
fake.add_provider(                    fake.get_arguments(                   fake.pyint(
fake.address(                         fake.get_formatter(                   fake.pyiterable(
... I've removed a whole bunch for brevity's sake.
fake.free_email(                      fake.psv(                             fake.zipcode_in_state(
fake.free_email_domain(               fake.pybool(                          fake.zipcode_plus4(
fake.future_date(                     fake.pydecimal(
fake.future_datetime(                 fake.pydict(
>>> fake.

If you are using Python 3.9, 3.10, or 3.11, you will see: Nothing. Nothing happens when you hit [TAB] after typing fake.

This is Python saying it should work: https://docs.python.org/3.11/tutorial/interactive.html#tab-completion-and-history-editing. (Docs here are the same in all versions of Python)

CelestialGuru commented 1 year ago

The following works in every version of Python:

>>> class Foo:
...     aa = 1
...     def ab(self): pass
...     ba = 2
...     def bb(self): pass
...
>>> foo = Foo()
>>> foo.

Pressing [TAB]:

foo.aa    foo.ab()  foo.ba    foo.bb()
>>> foo.

I even tried building synthetic classes which have many attributes:

>>> import itertools, string
>>> Foo = type("Foo", (), {name:lambda self:1 for name in list(map("".join, itertools.product(*[string.ascii_lowercase]*3)))})
>>> foo = Foo()
>>> foo.

Press [TAB]

... thousands of results (17,576 to be exact) show up but I've hidden them for brevity's sake
>>> foo.

So it's not even that newer versions of Python are hiding them if there's too many.

So, why is it that fake. [TAB] shows nothing in newer versions of Python but only does in older versions?

stefan6419846 commented 1 year ago

This has already been reported in the past: https://github.com/joke2k/faker/issues/1604

CelestialGuru commented 1 year ago

The issue was closed. Should I attempt to reopen #1604, or is creating this new issue the correct course of action?

fcurella commented 1 year ago

You should reopen #1604. I'm closing this one as duplicate