Questions tagged [pylance]

Pylance is an extension for Visual Studio Code that provides a language server for Python. When applying this tag to your question, consider also tagging it with [visual-studio-code] and/or [python].

Pylance is a language server to support the core Python extension for Visual Studio Code. Its aim is to help developers write Python code better and faster by providing auto-imports, semantic highlighting, built-in reporting of warnings and errors, strict type-checking, and method signatures with type information when displaying the popup Intellisense documentation.

It was first introduced in a post on Microsoft's Python development blog: Announcing Pylance: Fast, feature-rich language support for Python in Visual Studio Code:

To deliver an improved user experience, we’ve created Pylance as a brand-new language server based on Microsoft’s Pyright static type checking tool. Pylance leverages type stubs (.pyi files) and lazy type inferencing to provide a highly-performant development experience. Pylance supercharges your Python IntelliSense experience with rich type information, helping you write better code, faster. The Pylance extension is also shipped with a collection of type stubs for popular modules to provide fast and accurate auto-completions and type checking.

It was made available starting VS Code 1.49 (2020.8.0 (12 August 2020) release).

  1. Expose Pylance setting in python.languageServer. If Pylance extension is not installed, prompt user to install it. (#13122)

Installation is straightforward:

  1. Install the Pylance extension
  2. Configure your settings.json file
    "python.languageServer": "Pylance",
    
  3. Open a .py file and the extension should activate

For more information:

465 questions
-1
votes
2 answers

Cannot import 'commands' from Discord.ext

My code: import discord from discord import commands from discord import client client = commands.Bot(command_prefix="!") @client.event async def on_ready(): print("Ready") @client.command() async def ping(ctx): await…
-1
votes
1 answer

Python cleaning and visual improvement

I'm just starting to learn python, specifically pygame, and am trying to make a simple jumping game. I made a basic movement script as a test, but the animations are really choppy. Whenever the block moves, there's an afterimage, and it looks like…
Loaphs
  • 33
  • 4
-2
votes
1 answer

"var_name is not accessed Pylance" is wrong

For some reason, Pylance gives me many such warnings even though the variables are used! Here is an example: breach = limits["breach"] if len(breach) > 0: message = str(breach)[1:-1] Here it will say breach is not accessed, even though I'm…
-2
votes
1 answer

Pylance syntax highlighting randomly stopped working (mac)

The syntax highlighting feature of Pylance randomly stopped working today (nothing obvious that I was doing that triggered it, just stopped). This is what it looks like now - before the variables and modules were in different colors, like…
Phil
  • 51
  • 5
-2
votes
2 answers

python unable to identify else statements

from requests import * import json import base64 import urllib from cmd import Cmd url = "http://api.response.htb/" url_digest = "cab532f75001ed2cc94ada92183d2160319a328e67001a9215956a5dbf10c545" def get(url, url_digest): data = { "url":…
-2
votes
3 answers

'input' is not defined Pylance(reportUndefinedVariable)

it just started happening, now all "input()" gets yellow underline But code works properly
Saurab
  • 11
  • 2
-2
votes
1 answer

Import "flask" could not be resolved Pylance

I am getting this missing import error. I tried installing flask and flask alchemy again but it says requirement satisfied
-2
votes
1 answer

Pylance Generic class type cannot be assigned from typing.get_args()

I have a Literal type of particular string values. I'm trying to generate a list of those strings as well dynamically: from typing import List, Literal, get_args Color = Literal['red', 'green', 'blue'] colors = List[Color] = get_args(Color) The…
Michael Moreno
  • 947
  • 1
  • 7
  • 24
-2
votes
1 answer

openCV is not found when importing

I am just starting in python and am trying to experiment with cv2, but whenever I try to import it I get the same error: Import "cv2" could not be resolved I have tried every possible way of installing it, I have…
-3
votes
1 answer

How to find what pylance considers Python stdlib?

While using Python with visual studio code, I’ve seen pylance mention stdlib. What does pylance consider python’s stdlib? I’m guessing it looks for stdlib dir based on some setting, but I don’t know what the setting is, where to find it, or what…
user3731622
  • 4,844
  • 8
  • 45
  • 84
-3
votes
1 answer

Pylance has two same resolution results

I am coding python script using vscode with extensions of Python and Pylance. I met a problem as the picture below there are two same resolution results at the same time, and not only for the import; any other place like resolving variables,…
-3
votes
1 answer

ModuleNotFoundError: No module named 'modeladapter'

So I want to run a repo i cloned from github project that is used to segregate the medical reports data and categorise it using machine learning and an error occurred. Here is the relevant code: import modeladapter as ModelAdapter VSCode…
-3
votes
1 answer

How to split a python program?

First, I'm sorry for these stupid questions. I'm try to looking for how to split my python program in different part. I have a file .py and in this file there is all my program. I would like to split this in 3 different file: Main, constant and…
TimoCF
  • 1
  • 2
-4
votes
1 answer

To recognition the face

I am write the code to recognition the face and mark attendence but so Error come and when i run the project the camere are open but not recogition the face the give face are stick on the camera screen. and the following error is are has follw: File…
Vaibhav
  • 1
  • 1
1 2 3
30
31