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

Not getting type hint sugesstion in vs code 🙏🙏🙏 #2035

Closed
RanaRana10 opened this issue Apr 26, 2024 · 15 comments
Closed

Not getting type hint sugesstion in vs code 🙏🙏🙏 #2035

RanaRana10 opened this issue Apr 26, 2024 · 15 comments

Comments

@RanaRana10
Copy link

  • Faker version: latest Faker 24.14.0

Here my question is after i defines,

fake = Faker()

and then i try to use fake.name, fake.address etc, i though when i write the dot(.) i should get some type hint sugestion of list parameter or fun or so on which i thought we should see it,

image

image

see i am not getting any sugesstion but when i use other library or suppose i am using, the random

image
see like this case i am getting sugesstion , like this, how i can get type hint when using this faker libarry in my vs code, as for otehr libaryr i use i always see the type hint

@stefan6419846
Copy link
Contributor

stefan6419846 commented Apr 26, 2024

With #1939, faker started providing a proxy.pyi stub file which should be picked up by your IDE in theory. Although for some reason, the corresponding stubs are omitted from the binary distributions at the moment: 6182c3e

@stefan6419846
Copy link
Contributor

Could you please try to update to the latest version and try again?

@mishamsk
Copy link

mishamsk commented May 1, 2024

@stefan6419846 installing faker from git does work now, so it should be a matter of pushing a new release

@stefan6419846
Copy link
Contributor

Version 24.14.1 has been released already including the corresponding fix: https://github.com/joke2k/faker/blob/refs/tags/v25.0.0/CHANGELOG.md#v24141---2024-04-28

@mishamsk
Copy link

mishamsk commented May 1, 2024

I didn’t test 24.14.1, but 25.0.0 doesn’t package pyi file

@stefan6419846
Copy link
Contributor

I do not know how the release bundles are built, but running the usual python -m build . locally with the latest code generates a wheel file which indeed includes the faker/proxy.pyi file. Thus we probably have to wait for @fcurella to clarify this.

@mishamsk
Copy link

mishamsk commented May 1, 2024

yeah, this works too pip install git+https://github.com/joke2k/faker.git which is more or less the same. However, downloading the latest version from pypi clearly shows that sdist includes the stub, but wheel doesn't:
CleanShot 2024-05-01 at 15 11 49@2x

tbh I've never used vanilla python build backend, so not sure why this is happening. My best guess is that it should also be included here:

faker/setup.py

Line 66 in 7f5dc14

"faker": ["py.typed"],

@RanaRana10
Copy link
Author

i still not understand how i can allow the type sugesstion in vs code like i want to see the sugession when write

fake.name() fake.addre it should show a sugesstion fake.address like autocomplite, but i dont get any , i want to say this problem, can you say more
image
i wish here should show a sugession like .address

@RanaRana10
Copy link
Author

see what i say why the type hint need, see this example,

image

when i move my mouse cursor to this i expect this will show "int" return , but it always shows any, this maybe need to solve, as actual returns need to show here

@fcurella
Copy link
Collaborator

fcurella commented May 2, 2024

I've just released v25.0.1. Could you give it a try?

@stefan6419846
Copy link
Contributor

I just had a look at the wheel and the file seems to be part of it now:

Archive:  Faker-25.0.1-py3-none-any.whl
  inflating: faker/__init__.py       
  inflating: faker/__main__.py       
  inflating: faker/cli.py            
  inflating: faker/config.py         
  inflating: faker/documentor.py     
  inflating: faker/exceptions.py     
  inflating: faker/factory.py        
  inflating: faker/generator.py      
  inflating: faker/proxy.py          
  inflating: faker/proxy.pyi         
  inflating: faker/py.typed          
  inflating: faker/typing.py         
  inflating: faker/contrib/__init__.py  
[...]

@RanaRana10
Copy link
Author

i am not good enough in python, i dont understand the things you have said,
i ask you , do you understand what things i means to say here,

like this i want to say in the docs of faker it says a lot of things available, like in the official docs it shows alot of list but when i do this

from faker import Faker
fake = Faker()

and then use fake, is this here any issue, or providers what it say, i mostly want for type hint, as one example is,

a fun which returns string, and after write the fun when i write (fun()). then here shows a lot of string related type hint, when a fun returns a int, it shows int related type hint, like this, so this will mroe helpful, that why i am saying about the type hint in this faker

image
image

so that if vs code give sugesstion and we can know what a fun will return what kind of obj, then we can perform the operation on this obj easily

image

like this case i want to get the lower letter, so for this, as when i press . i dont get any type hint , so i mistakes sometime wehre to give the lower()
as 2nd and 3rd line username gives same expected reasult which is to use

@stefan6419846
Copy link
Contributor

Please upgrade to the latest version and try again. In theory, it should work now as the required file is being shipped now.

@fcurella
Copy link
Collaborator

fcurella commented May 2, 2024

@RanaRana10 you can check Faker's version with Faker.VERSION:

>>> import faker
>>> faker.VERSION
'25.0.1'

@RanaUniverse
Copy link

Owo boss, Thanks you all ❤❤❤

it really works as we expected,
image

image

it really make our code experience so much speed 😘😘😘
it works so much easy now, i never thought in so little time you have fixed this issue in just a week, it is really a so easy to use library now☑☑☑

and like this type hint, is really so so so much helpful, i cannot express my enjoyment with this,

image

image

this type of hint direct in the code editor is really so much easy ❤❤❤

@fcurella fcurella closed this as completed May 2, 2024
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