Spyder: Let users set the file type by selecting it from a menu

Created on 17 Feb 2015  Â·  16Comments  Â·  Source: spyder-ide/spyder

_From pierre.raybaut on 2011-04-22T03:55:57Z_

See this thread: http://groups.google.com/group/spyderlib/browse_thread/thread/ac0feaf23790c4ef "2. File Association

  • Basically I can't open files from within spyder if file extension is
    not recognized
    (i.e. 'tac', which is just a python code from the twisted library)
  • Probably file association can also be made configurable similar to
    PyDev "

_Original issue: http://code.google.com/p/spyderlib/issues/detail?id=638_

6–10 stars Help wanted Editor Enhancement

Most helpful comment

Ok, I was asking because adding support for any file extension to be recognized as a Python file is hard. But we can tell Spyder what specific extensions it can recognize as such.

We'll add support for it in our 4.2.1 version, to be released just before Christmas.

All 16 comments

_From pierre.raybaut on 2011-05-16T01:30:55Z_

Labels: Cat-Settings

_From pierre.raybaut on 2012-03-18T14:11:02Z_

Labels: -Type-Enhancement Type-Enh

_From [email protected] on 2013-07-19T14:05:56Z_

It seems to me that rather than having a list of file types to include, it would be better to go the other direction and exclude certain file types. Files with an unrecognized extension would just be opened as plain text (perhaps with some attempt to detect encoding). I think this is what most other editors do: if it's not a known type, fall back to plain text. I think that's also the right behavior most of the time, too.

_From fedebaka on 2013-12-10T20:08:44Z_

+1 having this issue (discussedin the mailing list with @-ccordoba)

Files not having .py extension are open but not colored, interpreted, ran or debugged.

Could just remove file filters, make them optional or at least as ccordoba said, check for a python shebang on the first line of the file (though personally I would vote for letting the user open a file as py even if doesn't have that first line.

_From ccordoba12 on 2013-12-10T21:40:00Z_

Labels: MS-v2.3

_From contrebasse on 2013-12-11T00:27:33Z_

I think that the easier way is to be able to force the type of the file. It wouldn't change the current behavior and would permit to fully configure the file type. The problem if spyder tries to guess is that if it is wrong the user can't do anything. Many editors have a menu with all known file types for this purpose.
Detecting the shebang would be a nice addition in every case, though. It is very common to trip the extension for python scripts.

_From ccordoba12 on 2013-12-11T12:40:50Z_

Labels: -MS-v2.3 MS-v2.3.1

_From ccordoba12 on 2014-07-15T09:26:41Z_

This is a very interesting idea but we need someone to implement it. I'm going to improve shebang detection for 2.3.1 though.

Summary: Editor: Let users set the file type by selecting it from a menu (was: Editor: add a preference page to customize file associations)
Status: HelpNeeded
Owner: ---
Labels: -MS-v2.3.1 MS-v2.4

_From ccordoba12 on 2014-07-15T15:09:25Z_

This issue was updated by revision 2d4ef8a5d4cc .

_From ccordoba12 on 2014-09-21T11:08:08Z_

This is a functionality most Editors/IDEs have. I think it needs to go under the Source menu.

Labels: Easy

I voiced my need for this functionality almost a year ago under the old ticket #3270 - and the need remains dire!

Anyone who wants to use Spyder for Python development in conjunction with ArcGIS is going to need this functionality because ArcGIS's Python toolboxes have a .pyt file extension - which currently kills all syntax highlighting, tab completion, etc.

As per the following link, PyCharm can gracefully support Python syntax in .pyt files (unfortunately, I dislike pretty much everything else about PyCharm): http://bryanprice.net/pycharm-live-templates.html

Would love to see this functionality in Spyder, as it is by far my IDE of choice!!!

Hey @tjhallum, thanks for the feedback. Is .pyt the only extension you need Python support for? Or are there other similar ones?

@ccordoba12, I’m sure that others probably have use cases needing Python support for additional file extensions, but I only need Python support for the .pyt extension at this time.

Thank you!

Ok, I was asking because adding support for any file extension to be recognized as a Python file is hard. But we can tell Spyder what specific extensions it can recognize as such.

We'll add support for it in our 4.2.1 version, to be released just before Christmas.

@ccordoba12, AWESOME! Thank you!!!

@tjhallum, see pull request #14444.

Was this page helpful?
0 / 5 - 0 ratings