microsoft / pylance-release

Documentation and issues for Pylance
Creative Commons Attribution 4.0 International
1.71k stars 765 forks source link

Wrong highlight on lastest pre-release version #5672

Closed EeyoreLee closed 7 months ago

EeyoreLee commented 7 months ago

Type: Bug

Behaviour

Here's a code snippet

import glob
import itertools
import os
from datetime import datetime

import joblib
import numpy as np
import optuna
import pandas as pd
import polars as pl
from sklearn.feature_extraction import FeatureHasher
from sklearn.model_selection import train_test_split
from xgboost import XGBRegressor

df_so = pd.concat([pd.read_pickle(i) for i in so_file_list[-5:]])
df_so = df_so[df_so["customer_code"].isin(df_C2_customer["customer_code"].unique())
              & df_so["inner_code"].isin(df_eval_inner_code["inner_code"].unique())]

the lastest line show the wrong highlight, like a condition branch that will never be enter. image

Diagnostic data

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

``` XXX ```

Extension version: 2024.2.1 VS Code version: Code 1.87.2 (863d2581ecda6849923a2118d93a088b0745d9d6, 2024-03-08T15:20:17.278Z) OS version: Windows_NT x64 10.0.19045 Modes: Remote OS version: Linux x64 6.5.0-15-generic Remote OS version: Linux x64 6.5.0-15-generic Remote OS version: Linux x64 6.5.0-15-generic Remote OS version: Linux x64 6.5.0-15-generic

User Settings

``` languageServer: "Pylance" ```

Installed Extensions |Extension Name|Extension Id|Version| |---|---|---| |autoDocstring - Python Docstring Generator|njpwerner.autodocstring|0.6.1| |C/C++|ms-vscode.cpptools|1.19.9| |C/C++ Extension Pack|ms-vscode.cpptools-extension-pack|1.3.0| |CMake Tools|ms-vscode.cmake-tools|1.17.17| |Code Runner|formulahendry.code-runner|0.12.1| |Flake8|ms-python.flake8|2023.10.0| |Git Graph|mhutchie.git-graph|1.30.0| |Git History|donjayamanne.githistory|0.6.20| |isort|ms-python.isort|2023.13.10681007| |JavaScript Debugger|ms-vscode.js-debug|1.87.0| |LeetCode with labuladong|labuladong.leetcode-helper|1.5.4| |Markdown All in One|yzhang.markdown-all-in-one|3.6.2| |Pylance|ms-python.vscode-pylance|2024.3.1| |Python|ms-python.python|2024.3.10791010| |Python Debugger|ms-python.debugpy|2024.3.10791014| |Table Visualizer for JavaScript Profiles|ms-vscode.vscode-js-profile-table|1.0.8| |XMake|tboox.xmake-vscode|2.3.0| |yapf|eeyore.yapf|2023.12.104100706|
System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i9-10900 CPU @ 2.80GHz (20 x 2808)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled| |Load (avg)|undefined| |Memory (System)|31.72GB (19.89GB free)| |Process Argv|--crash-reporter-id 4baf125c-2259-4b73-9502-2a194b881560| |Screen Reader|no| |VM|0%| |Item|Value| |---|---| |Remote|SSH: workspace| |OS|Linux x64 6.5.0-15-generic| |CPUs|13th Gen Intel(R) Core(TM) i9-13900K (32 x 800)| |Memory (System)|125.56GB (83.95GB free)| |VM|0%| |Item|Value| |---|---| |Remote|SSH: workspace| |OS|Linux x64 6.5.0-15-generic| |CPUs|13th Gen Intel(R) Core(TM) i9-13900K (32 x 800)| |Memory (System)|125.56GB (83.95GB free)| |VM|0%| |Item|Value| |---|---| |Remote|SSH: workspace| |OS|Linux x64 6.5.0-15-generic| |CPUs|13th Gen Intel(R) Core(TM) i9-13900K (32 x 800)| |Memory (System)|125.56GB (83.95GB free)| |VM|0%| |Item|Value| |---|---| |Remote|SSH: workspace| |OS|Linux x64 6.5.0-15-generic| |CPUs|13th Gen Intel(R) Core(TM) i9-13900K (32 x 800)| |Memory (System)|125.56GB (83.95GB free)| |VM|0%|
A/B Experiments ``` vsliv368:30146709 vspor879:30202332 vspor708:30202333 vspor363:30204092 vscod805:30301674 binariesv615:30325510 vsaa593:30376534 py29gd2263:30899288 c4g48928:30535728 azure-dev_surveyone:30548225 2i9eh265:30646982 962ge761:30959799 pythongtdpath:30769146 welcomedialogc:30910334 pythonidxpt:30866567 pythonnoceb:30805159 asynctok:30898717 pythontestfixt:30902429 pythonregdiag2:30936856 pyreplss1:30897532 pythonmypyd1:30879173 pythoncet0:30885854 h48ei257:30992801 pythontbext0:30879054 accentitlementst:30995554 dsvsc016:30899300 dsvsc017:30899301 dsvsc018:30899302 cppperfnew:30979542 d34g3935:30971562 fegfb526:30981948 bg6jg535:30979843 ccp2r3:30993541 dsvsc020:30976470 jchc7451:30973076 7ghi1836:30988842 ```
debonte commented 7 months ago

This is a duplicate of #5630. The underlying issue was in pandas-stubs. They have fixed it and their fix will ship in our next prerelease build, likely today.

In the meantime there's a workaround described here: https://github.com/microsoft/pylance-release/issues/5630#issuecomment-1994616891

debonte commented 7 months ago

This issue is also fixed in our most recent stable release -- 2024.3.2