Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Python

Resolving import errors reported by PyLint in modules using Python.NET

 

 

Python python RSS feed   Index | Next | Previous | View Threaded


adam.preble at gmail

Aug 8, 2013, 10:17 PM

Post #1 of 3 (18 views)
Permalink
Resolving import errors reported by PyLint in modules using Python.NET

PyLint can't figure out imports of .NET code being referenced in my Python scripts that use Python.NET. I can kind of see why; you have to evaluate some clr.AddReference calls for the imports to even succeed. I wonder if I have any recourse. Generally, to import a DLL you have to do a few things. I guess for an example I'll import a .NET string:

----
import clr # Python .NET common-language runtime module, the important part of it all

clr.AddReference("System")
from System import String # .NET System.String

can = String("Spam")
----

PyLint is not amused:
F: 4, 0: Unable to import 'System' (import-error)

I wondered if there were any tricks to make it work. I don't want to just ignore import-error, either by explicitly telling pylint to ignore them, or be getting complacent in seeing them all the time. I am also kind of curious if PyLint will expose new problems if it's able to figure out more things after successfully passing the imports. I wouldn't really know.
--
http://mail.python.org/mailman/listinfo/python-list


benjamin.kaplan at case

Aug 8, 2013, 10:47 PM

Post #2 of 3 (14 views)
Permalink
Re: Resolving import errors reported by PyLint in modules using Python.NET [In reply to]

On Thu, Aug 8, 2013 at 10:17 PM, <adam.preble [at] gmail> wrote:
> PyLint can't figure out imports of .NET code being referenced in my Python scripts that use Python.NET. I can kind of see why; you have to evaluate some clr.AddReference calls for the imports to even succeed. I wonder if I have any recourse. Generally, to import a DLL you have to do a few things. I guess for an example I'll import a .NET string:
>
> ----
> import clr # Python .NET common-language runtime module, the important part of it all
>
> clr.AddReference("System")
> from System import String # .NET System.String
>
> can = String("Spam")
> ----
>
> PyLint is not amused:
> F: 4, 0: Unable to import 'System' (import-error)
>
> I wondered if there were any tricks to make it work. I don't want to just ignore import-error, either by explicitly telling pylint to ignore them, or be getting complacent in seeing them all the time. I am also kind of curious if PyLint will expose new problems if it's able to figure out more things after successfully passing the imports. I wouldn't really know.

Are you using Python.NET or IronPython? IronPython is reasonably well
supported, and it looks like there's a patch you can use to get PyLint
working on it (see
http://mail.python.org/pipermail/ironpython-users/2012-June/016099.html
). Not sure what's going on with Python.NET
--
http://mail.python.org/mailman/listinfo/python-list


adam.preble at gmail

Aug 11, 2013, 9:21 PM

Post #3 of 3 (3 views)
Permalink
Re: Resolving import errors reported by PyLint in modules using Python.NET [In reply to]

I thought I responded to this. Oh well <shrugs>

On Friday, August 9, 2013 12:47:43 AM UTC-5, Benjamin Kaplan wrote:
> Are you using Python.NET or IronPython? IronPython is reasonably well
>
> supported, and it looks like there's a patch you can use to get PyLint
>
> working on it (see
>
> http://mail.python.org/pipermail/ironpython-users/2012-June/016099.html
>
> ). Not sure what's going on with Python.NET

Definitely Python.NET in this case. It looks like that issue is different than what I get. PyLint just gets import errors when trying to import the modules, which it just reports with everything else I've done wrong.
--
http://mail.python.org/mailman/listinfo/python-list

Python python RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.