![]() It's because my pylintrc has indent-after-paren=2. I found out that the pylint error Wrong hanging indentation (remove 2 spaces). Why is it doing this and how can I make it 2 spaces everywhere? But when I paste or save (I have "editor.formatOnPaste" and "editor.formatOnSave" set to true), the annoying thing happened: all the 2-space indentation inside the parentheses became 4 (other 2-space indentation are unaffected). Press enter after an open parenthesis, it correctly starts the new line with 2 more spaces. When I press enter, it correctly starts the next line with the same indentation as the previous line. I found here that autopep8 can be configured to use 2 spaces by "8Args": I'm using VS Code with Python extension which uses autopep8 for formatting. Still not working? Click in the "OUTPUT" tab sibling of the TERMINAL and try to get more info at the "Log" output.I'm trying to get autopep8 work to properly indent Python code with 2 spaces instead of 4. You also can install using Conda, but in my experience VSCode works better with pip. ![]() Just install black using the interpreter from the venv: python -m pip install black. Type "help", "copyright", "credits" or "license" for more information.įailed import? Problem solved. Run python using your interpreter path and try to import black: $ python Since you selected your interpreter, your virtual environment should be automatically activated by VSCode. The status bar should change after selecting it. You can also do it with Ctrl-P + "Python: Select Interpreter". If you didn't explicitly select an interpreter, do it now clicking on the Python version in your status bar. I recommend the use of virtual environments, but first check your python interpreter on the status bar: That said, these kind of problems usually are about using a python interpreter where black isn't installed. In my settings I enabled the 'editor.formatOnSave': true and the formatter I use is autopep8. Remember that there may be 2 setting.json files: one in your home dir, and one in your project (. In tutorial 5 he splits his app into a package structure and when I do it I run into a problem. Just run from the command line if you need to format a lot of files at once.įirst, check if you have this in your VSCode settings.json (open it with Ctrl-P + settings): "": "black", It's best to use it from your favorite editor. It frees mental cycles that you would spend deciding how to format your code. I use Black from inside VSCode and it rocks. Yes, honestly, I am not sure which source_file_or_directory I should set.but above all now I am afraid whether I am on the right track or not.Ĭan I hear your advice? At least some direction to go, please. The bottom code is from settings.json (on vscode folder). Setting(VSCode) -> flake8, Python > Linting: Flake8 Enabled (Also modified in: workspace), (ticked the box) Whether to lint Python files using flake8 ![]() ![]() Manually input "": "black", to 'settings.json' on '.vscode' folder. Manually input 'pipenv install flack -dev -pre' on terminal. When I installed and set VSCode formatter 'black' (after setting linter as flake8), the tutorial video tutor's side shows up pop-up like 'formatter autopep8 is not installed. I have started using Python and Django and I am very new in this field.Īnd, this is my first time to ask a question here.I do apologise in advance if there is a known solution to this issue. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |