First of all, this is my first post, so I hope I'm following the proper guidelines and am stating the issue clearly.
I'm personally not too Linux-savvy, only using it to do some code on occasion, though I do most of that in Windows. To be more precise, I've run into the following issue while running Manjaro on a virtual machine.
Today, while using the PyQt5 library, I noticed a small annoyance. In general, Linux assumes all files ending with .py are python scripts. However, if I happen to have some code which imports PyQt AND has any sort of { brackets, then Manjaro immediately lists it as a "Qt Markup Language" file. Here's some dummy code that replicates the issue saved as "test.py"
#!/usr/bin/env python3
from PyQt5 import QtWidgets
some_dict = {}
Adding the shebang didn't do much. If I erase either the second OR the third line, the OS says its file type is "Python script", but if I keep both, then it infers it as a QML (Qt Markup Language file), because of the brackets (I assume). This also happens if I format strings with f'' or with .format(), so I know it's not just a dictionary issue.
This has no impact whatsoever on my code, but I still find it mildly annoying and I'd like to know how:
- Linux infers file types since it doesn't care much for extentions
- How I can change this if there's a quick solution
Like I said, this is no big deal, especially since I do my editing using the terminal, but it bothers me and makes me curious. Thanks for your help and have a great day!
UPDATE 1: I browsed the wiki and found this: https://wiki.archlinux.org/index.php/XDG_MIME_Applications#mimeapps.list
I can successfully replicate their example, but so far am having issues adapting this to .py files. Even after I set the new rules, it seems to still browse the configuration files in /usr/share/mime.
UPDATE 2: I'm still unable to write rules that successfully override what's considered a QML when the extention is .py. However, if I replace the import statement with
import PyQt5.QtWidgets as QtWidgets
then I'm able to "trick" the rules and it now successfully labels it as a "Python Script file". The "issue" itself wasn't solved, but I actually learned a lot from this.
In general, Linux assumes all files ending with .py are python scripts
- no, it doesn't.OS says its file type is "Python script"
- how are you checking it?Properties
and it saysKind: Python script
.