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

Allow user customization of type stubs (for example to help with completions when using IronPython). #5027

Closed
zhouwangyang opened this issue Jan 29, 2019 · 29 comments
Labels

Comments

@zhouwangyang
Copy link
Contributor

VS Version: 28526.9.d16.0stg
Python Tool Version: 16.0.19026.2
Repro step:
1.Create an IronPython WPF Application
2.Drag & drop a button to the Design view
3.Check the IntelliSense in the .py file
a. From System.Windows import MessageBox
b. In the Button_Click handler, add a call to MessageBox.Show()
c. Signature info tooltip shows all overloads

expect result:
a. code coloring with Messagebox
b. when type MessageBox. , Show() should appear automatically
c. signature info tooltip shows with MessageBox

actual result:
a. no code coloring with Messagebox
b. no completions when type MessageBox.
c. no signature info tooltip shows with MessageBox
image

@huguesv huguesv changed the title No completions with MessageBox in WPF Application No completions on .NET types in WPF Application Feb 25, 2019
@huguesv huguesv changed the title No completions on .NET types in WPF Application No completions when using IronPython Feb 25, 2019
@huguesv
Copy link
Contributor

huguesv commented Feb 25, 2019

Some standard library modules have completions (json) but others don't (sys).

@slozier
Copy link

slozier commented Apr 23, 2019

It works on modules implemented in Python (e.g. json, os), but fails with anything that's built-in/.NET (e.g. sys, nt).

@ccc159
Copy link

ccc159 commented Jul 17, 2019

any news on this?

@mdfynadamas
Copy link

any news?

@AtomicZ
Copy link

AtomicZ commented Sep 12, 2019

As an interim solution, it sure would be nice to have the ability to supplement with auto-complete stubs like Visual Studio Code can do. Can we just get a folder where we can put stubs?

https://github.com/gtalarico/ironpython-stubs

@huguesv
Copy link
Contributor

huguesv commented Sep 12, 2019

@AtomicZ you could try placing them under the typeshed that we install in the Python extension folder (searching for typeshed under the VS install folder should find it). They probably need to go under typeshed/third_party/2

The location of the typeshed folder is supposed to be customizable, but this is an option that is not regularly tested anymore, and I am not sure of its current status. It can be set in tools/options/python/language server. You could take the typeshed in the install dir, copy it somewhere else and then add whatever you need to it, and put the location in tools/options. That way, you don't mess with the contents of the install dir, but again, not sure how well that works.

@huguesv
Copy link
Contributor

huguesv commented Nov 18, 2019

@gramster
Copy link
Member

We are not going to do any additional work specifically for IronPython; usage is too low and there are alternatives that work with Python 3.

We are planning on having much better support for type stubs in the future (sometime in first half of 2020). So I am going to rename this issue and change it to be about that.

@gramster gramster changed the title No completions when using IronPython Allow user customization of type stubs (for example to help with completions when using IronPython). Nov 20, 2019
@dbmercer
Copy link

dbmercer commented Dec 6, 2019

Can you confirm that this is the same issue reported at IronLanguages/ironpython2#615? There are pointers from that one to this one, but I cannot decipher this issue to figure out what the heck it is about. I thought IronLanguages/ironpython2#615 was pretty clear; this one not so much.

@huguesv
Copy link
Contributor

huguesv commented Dec 6, 2019

@dbmercer yes that is the same issue as the one you linked.

@Anapo14
Copy link

Anapo14 commented Dec 11, 2019

Hey there @dbmercer, @zhouwangyang and @AtomicZ. I would love to learn more about your use-cases with IronPython in Visual Studio. Do you mind emailing ptvshelp @ microsoft.com so we can continue a more detailed conversation there? Thank you!

@zhouwangyang
Copy link
Contributor Author

@Anapo14 I'd like to do that. What detailed information do you need to send by email?

@mmfontana
Copy link

Has someone solved it???

@dbmercer
Copy link

@mmfontana Not as far as I know.

@GLantaff
Copy link

Is fixing the "unresolved import" issues with IronPython still being worked on? And any guess what release to target? I would like to use VS 2019 but have to stay on 2017 till this gets resolved.

@huguesv
Copy link
Contributor

huguesv commented Apr 23, 2020

The "much better support for type stub" is being actively worked on, and will go in as part of the new language server & integration work.
#5210 (comment)

That is still many months away.

@mmfontana
Copy link

@GLantaff does it perfectly work in VS 2017?

@GLantaff
Copy link

@GLantaff does it perfectly work in VS 2017?

No not perfect but mostly OK. In 2019 every line that has an import statement is flagged as an error.
2017:
image
2019:
image

In 2019 you end up with so many warnings it's hard to find the real issues.
My request was never to fix intellisense (which would be great) but to fix all the false warnings about "unresolved import xxx"

@huguesv
Copy link
Contributor

huguesv commented Apr 24, 2020

There's an option to turn off unresolved import warnings:
image

@GLantaff
Copy link

That does help. Thanks. Still miss the color highlighting to show it found the class but this is a good work around for now.

@ThamSunc
Copy link

Is there any updates?
I'm working on Ironpython project in visual studio 2019, expecting to call function in COM type library .dll
But, even import clr doesn't work.

Will visual studio still support python or ironpython any longer ?

@ThamSunc
Copy link

@gramster
We are not going to do any additional work specifically for IronPython; usage is too low and there are alternatives that work with Python 3.

Would you explain what alternative that currently work with python 3?
And how could we do it?
I need to call function in COM typed library .dll

In version 2015 everything looks fine, even the intellisens we just need to add the interop library on reference browse tab.
But now, even in VS2017, the browse button isn't shown in add reference dialog.

@FrankSAURET
Copy link

You can import clr like this :

  • Run cmd as administrator
  • Go to ipy.exe directory (c:\program files\IronPython 2.7 for example)
  • run "ipy -X:Frames -m ensurepip "
  • run "ipy -X:Frames -m pip install clr"

Change name clr for other library

@dilipsharan
Copy link

You can import clr like this :

  • Run cmd as administrator
  • Go to ipy.exe directory (c:\program files\IronPython 2.7 for example)
  • run "ipy -X:Frames -m ensurepip "
  • run "ipy -X:Frames -m pip install clr"

Change name clr for other library
======================================================

Dilip: This above solution worked for me. The import clr in Visual Studio using Iron Python now works. Many Thanks

@IBIT-ZEE
Copy link

?still no solution,,,

@greazer greazer closed this as completed Jul 28, 2021
@rkolka
Copy link

rkolka commented Aug 9, 2021

@greazer What is the resolution? Won't fix? Use VS 2022? Use VS Code? IronPython support dropped?

@greazer
Copy link

greazer commented Aug 10, 2021

That is correct, IronPython is no longer supported in Visual Studio 2022. However, VS 2022 does use PyLance for the language service. You can configure the type stub paths in Tools->Options

image

@gramster
Copy link
Member

gramster commented Aug 10, 2021

To be precise - you can still use IronPython as a Python interpreter, but its gone from the installer, there is no special support in the language server, and YMMV as Pylance is based on Python 3. Usage of IronPython is very low and it is very behind in modern Python features (stable release is still Python 2.7, which will not be supported in the next release of Visual Studio), so we don't plan on any special support and recommend it not be used. There are other ways of doing interop with .Net assemblies, if that is what you want to do (e.g. https://github.com/pythonnet/pythonnet).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests