In sublime3, how to override Anaconda plugin settings for current project? - python

I use sublime 3 for python coding, with plugin Anaconda for format checking. But when I read others' codes, I don't need this function, because the whole file is full of format error which I don't care about but the Anaconda lint bothers me. So I would like close the function for this "project" (not current file), what should I do?

You can control the state Anaconda linter using the anaconda_linting setting.
"anaconda_linting": false
Working with projects gives you more refined control where you want to use the linter and where not. For instance, you could disable the linter in your global settings and enable it for specific projects.

Related

VSCode mouse-hover on Python Keywords not working

While beginning to teach a friend how to code in Python, I observed something in his VSCode that was different than my own - he could mouse-hover on a Python keyword such as as import or def, and it would show the Python Manual definition for the keyword. My own VSCode does not do this.
I have tried everything I can think of to find why this won't work for me, and I'm at a complete loss. I have compared my installation process to my friend's, followed the exact same steps I provided him for setting up his environment, and do not get the same results. I tried completely removing Python, VSCode and all residual VSCode files from my laptop, and reinstalling in the same order he did, still to no avail.
I followed those same steps on a different laptop at work, and I can get the MouseHover to work there. The only feasible difference I can think of is that my work machine is not using the same Windows account as both my home PC and laptop - but I do not have Settings Sync enabled so I can't see why that should matter anyway.
Any thoughts for what I'm overlooking to get this functionality working properly in VSCode for myself? I don't particularly need it, but I'd like to be in the same environment as my friend while I teach him.
We're both on VSCode 1.55.2, Python 3.9.4, using a virtual environment created from VSCode's Powershell terminal, then restarted VSCode to get it to detect the virtual environment and use it as default for Terminals, and finally pip installed and enabled Pylint as the linter.
Editing to add steps followed - I just went through all of this again on my home laptop, after completely removing all traces of VisualStudio2019 and Code, and Python. Note: this was on Windows 10, with all updates applied
Install VSCode
Install VSCode Python extension, MS version
Install Python 3.9.4
Open a new folder in VSCode, then open Terminal
python -m venv venv
create a something.py in the Explorer pane
VSCode should detect the venv and offer to load it. Say yes
VScode may also indiacte that pylint is not installed, Allow it to install, or manually pip install pylint from the venv.
in something.py type out import random
Mouse over import -- this is the discrepancy. On both of my home machines, there is no mousehover anything. on both of my friend's machines, as well as my machine at work, the following is shown:
With help from riov8's comment on the original post, I was able to compare the Experiment Groups that were in effect for each of the environments.
In VSCode, with a Python file loaded, switch to the Output panel (in same area as Terminal) and change the dropdown to Python.
Scroll to the top of this panel, and examine the Experiment Groups you belong to.
Most of the experiment groups do not apply to this issue.
Look specifically for either pythonJediLSP, pythonJediLSPcf or if
you have neither.
If you are experiencing the issue I describe, then at the bottom of this same panel, when you first mouse over a python keyword after starting VSCode, you will get errors similar to the following:
Error 2021-04-16 15:33:40: stderr jediProxy Error (stderr) %UserProfile%\.vscode\extensions\ms-python.python-2021.3.680753044\pythonFiles\completion.py:598: DeprecationWarning: Providing the line is now done in the functions themselves like `Script(...).complete(line, column)`
sys_path=sys.path,
%UserProfile%\.vscode\extensions\ms-python.python-2021.3.680753044\pythonFiles\completion.py:598: DeprecationWarning: Providing the column is now done in the functions themselves like `Script(...).complete(line, column)`
sys_path=sys.path,
Error 2021-04-16 15:33:40: stderr jediProxy Error (stderr) %UserProfile%\.vscode\extensions\ms-python.python-2021.3.680753044\pythonFiles\completion.py:598: DeprecationWarning: Deprecated since version 0.17.0. Use the project API instead, which means Script(project=Project(dir, sys_path=sys_path)) instead.
sys_path=sys.path,
Error 2021-04-16 15:33:40: stderr jediProxy Error (stderr) %UserProfile%\.vscode\extensions\ms-python.python-2021.3.680753044\pythonFiles\completion.py:626: DeprecationWarning: Deprecated since version 0.16.0. Use Script(...).infer instead.
script.goto_definitions(), request["id"]
The following scenarios resolved the issue for me:
User belongs to experiment group pythonJediLSPcf:
File > Preferences > Settings
in Search Settings, begin typing python.experiment
under Python> Experiments: Opt Out From, click Edit in settings.json
in the section "python.experiments.optOutFrom", add "pythonJediLSPcf" (quoted)
if it does not exist, add another section "python.experiments.optInto"
In the OptInto section, add "pythonJediLSP" (quoted)
Save the settings.json, and restart VSCode.
MouseHover tooltips on Python keywords now should work.
User does not belong to either pythonJediLSPcf or pythonJediLSP:
File > Preferences > Settings
in Search Settings, begin typing python.experiment
under Python › Experiments: Opt Into, click Edit in settings.json
In the "python.experiments.optInto section, add "pythonJediLSP" (quoted)
Save the settings.json, and restart VSCode.
MouseHover tooltips on Python keywords now should work.
User belongs to pythonJediLSP:
It was my experience that this was the experiment required in order for the feature to work properly. If you have this experiment enabled already, then ensure you do not also have pythonJediLSPcf. Disable it if you do, following the instructions in the first sub-heading. If it continues to not work, then there may be another conflict that I did not experience myself.
I am posting a GitHub issue regarding this problem and will update this answer with the link when done.

Pycharm is not showing Pygame properties [duplicate]

I want to configure Pylint as an external tool in my entire project directory for a Python project that I'm working on. I've tried to use the repository as a module with __init__.py and without, and it's not working either way.
I'm having difficulty setting up Pylint to run with PyCharm. I know that I should be running it as an external tool, however the settings confuse me.
The authoritative source on their documentation is broken, so I can't check that up either.
You can set up Pylint to work with PyCharm by following the following steps:
Install pylint:
$ pip install pylint
Locate your pylint installation folder:
$ which pylint # MacOS/Linux
/usr/local/bin/pylint # This is just a possible output - check yours
<!-->
$ where pylint # Windows
%LocalAppData%\Programs\Python\Python36-32\Scripts\pylint.exe # Possible location
Open the PyCharm settings window with menu File → Settings, then navigate to menu Tools → External Tools in the sidebar. (Or search "external tools")
Set up an external tool by clicking on the + sign and filling in the fields accordingly. In Program use the path you got when running which pylint. For the other values, you can use the same from the image.
Run pylint from menu Tools → External Tools → pylint:
Look at your output in the PyCharm terminal
For more details, refer to Pylinting with PyCharm.
If you want to use Pylint to check your whole project or a particular file or directory, you can right click on your project root, file or directory, then activate External Tools → pylint as shown below.
Because I didn't find a working ready-made setup, these are the settings I use in PyCharm CE 2018.1 on macOS:
1 - pip install pylint in your project virtualenv or globally
2 - Add new external tool and configure:
Program: pylint
Arguments: "--msg-template='{abspath}:{line:5d},{column:2d}: {msg} ({symbol})'" --output-format=colorized "$FilePath$"
Working directory: $ProjectFileDir$
Output filters: $FILE_PATH$:\s*$LINE$\,\s*$COLUMN$:
Notice the required double quotes for the msg-template, and the escape chars for the output filters. The output filter allows to click on the file path and open the location in the IDE source editor.
Only missing feature would be the output filters to plot the lint descriptions directly into the source view, as is done with the builtin linter. No such feature at this time though.
You can try this Pylint PyCharm plugin:
It provides both real-time and on-demand scanning of Python files with Pylint from within PyCharm/IntelliJ IDEA.
Once you have it installed, the real-time inspection works automatically.
For the on-demand you have several options that go from just checking the current open file to scan the entire project:
(Just for the sake of transparency, I am the developer.)
I now use and recommend the PyCharm plugin which didn't exist when I first wrote this answer.**
A colleague pointed me towards pylint-pycharm on GitHub. It's a wrapper around Pylint with output formatted for PyCharm.
Here's how I set it up:
git clone https://github.com/perses76/pylint-pycharm.git
cd pylint-pycharm
python setup.py build
This creates build/scripts-2.7/pylint-pycharm
Then, in PyCharm, create a new External Tool with these settings:
Program: path to your installation of pylint-pycharm
Arguments: --virtualenv=$PyInterpreterDirectory$/.. $FileName$
Working directory: $FileDir$
Output filters: $FILE_PATH$\:$LINE$\:$COLUMN$\:.*
Now run it from menu Tools* → External Tools → PyLintPyCharm. Each line of output will be hyperlinked to the relevant position in the source code.
A note on the previous answers.
I was searching for a method to make PyCharm aware of the output syntax so I can directly jump to the file locations. That works without using additional tools.
Pylint can be configured to output messages in a specific format using the msg-template option in the pylintrc file or the CLI option --msg-template.
I set it to:
msg-template='{abspath}:{line}:{column}: {msg_id} {msg}'
In the External Tools settings, the Output filters: can be set to
$FILE_PATH$:$LINE$:$COLUMN$: .*
so PyCharm shows links to directly jump to the reported locations.
This can be combined with output-format=colorized so I get this:
PyCharm does not recognize the column despite having it configured. But having the file and line is enough for me.
At first install Pylint with pip:
pip install pylint
You have to open “Settings → Tools → External Tools“ and press the “+” button at PyCharm.
Here are an example with good settings.
Roberto Leinardi has created a Pylint plugin for PyCharm which really works and integrates well into the IDE:
Easy to install from the repositories, full instructions under:
pylint-pycharm
I have a short, yet a happy, experience with it so far! Kudos to Roberto.
Thanks to information here, and updated documentation from PyCharm, I've been able to get this to work nicely to also use the virtual environment for the project (ensuring that any packages can be deployed within the virtual environment and do not need to be deployed globally).
Taking what lkraider provided earlier, but with slight modifications:
Ensure you install Pylint within the virtual environment. Note, make sure that when you created the virtual environment you did not select "Inherit global site-packages". If you do then Pylint will end up being globally and this will not work.
Add a new external tool and configure. This is slightly different compared to what lkraider provided. For one I wanted it to look more like normal Pylint output, hence my msg-template (and Output filter) is a bit different. Each to their own.
The second change is the more critical one for executing Pylint based on the virtual environment. That is the program parameter where I use $PyInterpreterDirectory$.
Program: $PyInterpreterDirectory$/pylint
Arguments: "--msg-template='{abspath}:{line:5d}:{column}: {msg_id}: {msg} ({symbol})'" --output-format=colorized "$FilePath$"
Working directory: $ProjectFileDir$
Output filters: $FILE_PATH$:\s*$LINE$\:\s*$COLUMN$:
External tool for Pylint

VSCode Python package inspection failure

This's probably quite off-topic but maybe someone else share my experience... when I started coding KiCAD plugins and learning Python I decided to use VSCode (with Microsoft Python extension) because I already use it for a number of other things and works great.
I have two main issues mostly bound to Python extension itself other than VSCode:
VSCode try to use python 3.7 binary (I installed it on my
machine and I need it) instead kicad/python 2 (it's installed on a different location);
even if I setup VSCode to look for additional packages with a specific configuration file (settings.json):
"python.autoComplete.extraPaths": ["C:/Program Files/KiCad/lib/python2.7/site-packages"]
VSCode refuse to investigate pcbnew.py (located in that folder) and thus every Intellisense like function (inspection etc) doesn't work.
How can I fix that? ... I'm more interested in fixing the second issue other than the first.
To correctly enable per project configuration of VSCode / Python open folder and create a workspace configuration for the project itself (i.e. create a .vscode folder inside project folder and store a settings.json file inside it with you custom configuration). In my specific case I needed to specifiy a custom location for an older Python binary trough python.pythonPath directive.

Configuring python interpretor with pycharm

Whenever I am configuring python interpreter, on compiling a pop-up is popping up to edit, modify, or uninstall python ,below is the screenshot
The Auto Config feature of the IDE looks for it in the PATH set by the user.
Better way to do it is add it in your system variables from where the IDE could pick it up.
For Mac its under the Library\Frameworks\Python.framework\Versions\X.Y\bin\
For Windows its mostly under C:\PythonXY\python.exe
& For more 'what ifs' you can find it documented here.

Pycharm External tools relative to Virtual Environment

Using the PyCharm IDE, when setting up an external tool, how can you set up the external tools with a path relative to use the current virtual env defaults.?
An example being pylint - where I'd want the virtual env version and not the system one to run.
Not sure about older versions, but in PyCharm 5 one can use $PyInterpreterDirectory$ macro. It's exactly that we want
There's JDKPath macro you can use which points to the executable of the interpreter set for a project. You can combine this with the fact that many tools can be run by directly running their module(s) using the -m option of interpreter. Also there's issue PY-2734 New useful macros in external tools everyone can vote on.
just found your post while looking for documentation about the "variables" that could bew used when setting parameters for external tools.
No documentation but you can see a list of all the available stuff after pressing thE "INSERT MACRO" button in the Edit Tool dialog.
I don't see any reference to the interpreter path there but I usually use the virtualenv as my project path. If you are doing that too you could infer the python interpreter path from there.
In Tool Settings, set Program: to $PyInterpreterDirectory$/pylint

Categories

Resources