microsoft / pylance-release

Documentation and issues for Pylance
Creative Commons Attribution 4.0 International
1.68k stars 771 forks source link

valid @staticmethod causes warning #4844

Closed rlippmann closed 9 months ago

rlippmann commented 10 months ago

Environment data

Code Snippet

@staticmethod
    def _check_service_host(service_host: str) -> None:
        if service_host is None or service_host == "":
            raise ValueError("Service host is mandatory")
        if service_host not in (DEFAULT_API_HOST, API_HOST_CA):
            raise ValueError(
                "Service host must be one of {DEFAULT_API_HOST}" f" or {API_HOST_CA}"
            )

pylance reports:

Argument of type "(service_host: str) -> None" cannot be assigned to parameter "f" of type "() -> _R_co@staticmethod" in function "init__"   Type "(service_host: str) -> None" cannot be assigned to type "() -> _R_co@staticmethod"

Repro Steps

  1. XXX

Expected behavior

should be no error

Actual behavior

XXX

Logs

XXX
rchiodo commented 10 months ago

Thanks for the issue but I can't seem to reproduce it.

image

Can you include more of the code?

rlippmann commented 10 months ago

Here's another example in a different class:

class ADTPulseZones(UserDict):
    """Dictionary containing ADTPulseZoneData with zone as the key."""

    @staticmethod
    def _check_value(value: ADTPulseZoneData) -> None:
        if not isinstance(value, ADTPulseZoneData):
            raise ValueError("ADT Pulse zone data must be of type ADTPulseZoneData")

    @staticmethod
    def _check_key(key: int) -> None:
        if not isinstance(key, int):
            raise ValueError("ADT Pulse Zone must be an integer")

    def __getitem__(self, key: int) -> ADTPulseZoneData:
        """Get a Zone.

        Args:
            key (int): zone id

        Returns:
            ADTPulseZoneData: zone data
        """
        return super().__getitem__(key)

    def _get_zonedata(self, key: int) -> ADTPulseZoneData:
        self._check_key(key)
        result: ADTPulseZoneData = self.data[key]
        self._check_value(result)
        return result

    def __setitem__(self, key: int, value: ADTPulseZoneData) -> None:
        """Validate types and sets defaults for ADTPulseZones.

        ADTPulseZoneData.id_ and name will be set to generic defaults if not set

        Raises:
            ValueError: if key is not an int or value is not ADTPulseZoneData
        """
        self._check_key(key)
        self._check_value(value)
        if not value.id_:
            value.id_ = "sensor-" + str(key)
        if not value.name:
            value.name = "Sensor for Zone " + str(key)
        super().__setitem__(key, value)

    def update_status(self, key: int, status: str) -> None:
        """Update zone status.

        Args:
            key (int): zone id to change
            status (str): status to set
        """ """"""
        temp = self._get_zonedata(key)
        temp.status = status
        self.__setitem__(key, temp)

    def update_state(self, key: int, state: str) -> None:
        """Update zone state.

        Args:
            key (int): zone id to change
            state (str): state to set
        """
        temp = self._get_zonedata(key)
        temp.state = state
        self.__setitem__(key, temp)

    def update_last_activity_timestamp(self, key: int, dt: datetime) -> None:
        """Update timestamp.

        Args:
            key (int): zone id to change
            dt (datetime): timestamp to set
        """
        temp = self._get_zonedata(key)
        temp.last_activity_timestamp = int(dt.timestamp())
        self.__setitem__(key, temp)

    def update_device_info(
        self,
        key: int,
        state: str,
        status: str = "Online",
        last_activity: datetime = datetime.now(),
    ) -> None:
        """Update the device info.

        Convenience method to update all common device info
        at once.

        Args:
            key (int): zone id
            state (str): state
            status (str, optional): status. Defaults to "Online".
            last_activity (datetime, optional): last_activity_datetime.
                Defaults to datetime.now().
        """
        temp = self._get_zonedata(key)
        temp.state = state
        temp.status = status
        temp.last_activity_timestamp = int(last_activity.timestamp())
        self.__setitem__(key, temp)

    def flatten(self) -> List[ADTPulseFlattendZone]:
        """Flattens ADTPulseZones into a list of ADTPulseFlattenedZones.

        Returns:
            List[ADTPulseFlattendZone]
        """
        result: List[ADTPulseFlattendZone] = []
        for k, i in self.items():
            if not isinstance(i, ADTPulseZoneData):
                raise ValueError("Invalid Zone data in ADTPulseZones")
            result.append(
                {
                    "zone": k,
                    "name": i.name,
                    "id_": i.id_,
                    "tags": i.tags,
                    "status": i.status,
                    "state": i.state,
                    "last_activity_timestamp": i.last_activity_timestamp,
                }
            )
        return result

    def update_zone_attributes(self, dev_attr: dict[str, str]) -> None:
        """Update zone attributes."""
        dName = dev_attr.get("name", "Unknown")
        dType = dev_attr.get("type_model", "Unknown")
        dZone = dev_attr.get("zone", "Unknown")
        dStatus = dev_attr.get("status", "Unknown")

        if dZone != "Unknown":
            tags = None
            for search_term, default_tags in ADT_NAME_TO_DEFAULT_TAGS.items():
                # convert to uppercase first
                if search_term.upper() in dType.upper():
                    tags = default_tags
                    break
            if not tags:
                LOG.warning(
                    f"Unknown sensor type for '{dType}', " "defaulting to doorWindow"
                )
                tags = ("sensor", "doorWindow")
            LOG.debug(
                f"Retrieved sensor {dName} id: sensor-{dZone} "
                f"Status: {dStatus}, tags {tags}"
            )
            if "Unknown" in (dName, dStatus, dZone) or not dZone.isdecimal():
                LOG.debug("Zone data incomplete, skipping...")
            else:
                tmpzone = ADTPulseZoneData(dName, f"sensor-{dZone}", tags, dStatus)
                self.update({int(dZone): tmpzone})
        else:
            LOG.debug(
                f"Skipping incomplete zone name: {dName}, zone: {dZone} "
                f"status: {dStatus}"
            )
rlippmann commented 10 months ago

I tried your sample code, too, and it's giving me the same warning.

rchiodo commented 10 months ago

I'm still not reproing that specific error. Your example doesn't include a bunch of things though so maybe that's why. But if my example repros, that's easier to diagnose.

Can you show the exact error and where it's coming from?

rlippmann commented 10 months ago
DEFAULT_API_HOST = "https://portal.adtpulse.com"

class Test:
    def __init__(self):
        Test._check_service_host(DEFAULT_API_HOST)

    @staticmethod
    def _check_service_host(host):
        if host is None:
            raise Exception("Host is not set")
        if not host.startswith("https://"):
            raise Exception("Host is not valid")

Argument of type "(host: Unknown) -> None" cannot be assigned to parameter "f" of type "() -> _R_co@staticmethod" in function "init__"   Type "(host: Unknown) -> None" cannot be assigned to type "() -> _R_co@staticmethod"

Error is in line 7, column 6

[{ "resource": "/home/rlippmann/git/pyadtpulse/pyadtpulse/Untitled-1.py", "owner": "_generated_diagnostic_collectionname#6", "code": { "value": "reportGeneralTypeIssues", "target": { "$mid": 1, "path": "/microsoft/pyright/blob/main/docs/configuration.md", "scheme": "https", "authority": "github.com", "fragment": "reportGeneralTypeIssues" } }, "severity": 8, "message": "Argument of type \"(host: Unknown) -> None\" cannot be assigned to parameter \"f\" of type \"() -> _R_co@staticmethod\" in function \"init__\"\n  Type \"(host: Unknown) -> None\" cannot be assigned to type \"() -> _R_co@staticmethod\"", "source": "Pylance", "startLineNumber": 7, "startColumn": 6, "endLineNumber": 7, "endColumn": 18 }]

rlippmann commented 10 months ago

(not sure why it thinks the static method is part of init)

rchiodo commented 10 months ago

Maybe it's not picking up the right definition for staticmethod. What do you get when you hover over staticmethod:

image

erictraut commented 10 months ago

I suspect there's something corrupt with either your pylance install, your settings, or your virtual environment. Let's see if we can eliminate some of those. Could you try to repro the problem with a fresh project and a fresh virtual environment?

rlippmann commented 10 months ago

The same thing you get. If I change the static method above init, I get the same problem.

rlippmann commented 10 months ago

It goes away with a fresh project/virtualenv

rchiodo commented 10 months ago

Can you install all the same modules in the new virtual env and see if it repros? Trying to see if there's a specific package causing the problem or if it's in your source.

rlippmann commented 10 months ago

I created an entirely new virtualenv in the original project directory, and it repros.

rlippmann commented 10 months ago

Ok, closed the folder and reopened, and it went away.

rchiodo commented 10 months ago

Perhaps it is something in the original virtual environment then.

You should be able to list the contents of each (assuming they're venvs) and diff the pip list output.

rlippmann commented 10 months ago

I'm doing development for home assistant, so it's a pretty large set of packages.

rchiodo commented 10 months ago

If you list them here, we can try and reproduce the problem.

rlippmann commented 10 months ago

As an aside, issue https://github.com/microsoft/pylance-release/issues/4832 went away with the environment change.

rlippmann commented 10 months ago

Working environment:

Package               Version
--------------------- ---------
aiohttp               3.8.5
aiosignal             1.3.1
async-timeout         4.0.3
attrs                 23.1.0
beautifulsoup4        4.12.2
charset-normalizer    3.2.0
exceptiongroup        1.1.3
frozenlist            1.4.0
idna                  3.4
iniconfig             2.0.0
multidict             6.0.4
packaging             23.1
pip                   23.2.1
pluggy                1.3.0
pytest                7.4.2
pytest-asyncio        0.21.1
pytest-mock           3.11.1
python-dateutil       2.8.2
setuptools            59.6.0
six                   1.16.0
soupsieve             2.5
tomli                 2.0.1
types-beautifulsoup4  4.12.0.6
types-html5lib        1.1.11.15
types-python-dateutil 2.8.19.14
types-setuptools      68.2.0.0
uvloop                0.17.0
yarl                  1.9.2
rlippmann commented 10 months ago

Not working environment:

accuweather                      0.5.1
acme                             1.31.0
adax                             0.2.0
Adax-local                       0.1.5
adb-shell                        0.4.3
adext                            0.4.2
adguardhome                      0.6.1
advantage-air                    0.4.4
AEMET-OpenData                   0.2.2
aenum                            3.1.12
afsapi                           0.2.7
agent-py                         0.0.23
aio-geojson-client               0.18
aio-geojson-generic-client       0.3
aio-geojson-geonetnz-quakes      0.15
aio-geojson-geonetnz-volcano     0.8
aio-geojson-nsw-rfs-incidents    0.6
aio-geojson-usgs-earthquakes     0.2
aio-georss-client                0.11
aio-georss-gdacs                 0.8
aioairq                          0.2.4
aioairzone                       0.5.5
AIOAladdinConnect                0.1.56
aioambient                       2023.4.0
aioaseko                         0.0.2
aioasuswrt                       1.4.0
aioazuredevops                   1.3.5
aiobafi6                         0.8.0
aiobotocore                      2.1.0
aiocoap                          0.4.7
aioconsole                       0.6.1
aiodiscover                      1.4.16
aiodns                           3.0.0
aioeafm                          0.1.2
aioeagle                         1.1.0
aioecowitt                       2023.1.0
aioemonitor                      1.0.5
aioesphomeapi                    13.7.2
aiofiles                         23.1.0
aioflo                           2021.11.0
aiogithubapi                     22.10.1
aioguardian                      2022.7.0
aioharmony                       0.2.10
aiohomekit                       2.6.3
aiohttp                          3.8.4
aiohttp-cors                     0.7.0
aiohue                           4.6.2
aioimaplib                       1.0.1
aioitertools                     0.11.0
aiokafka                         0.7.2
aiolifx                          0.8.10
aiolifx-effects                  0.3.2
aiolifx-themes                   0.4.5
aiolivisi                        0.0.19
aiolookin                        1.0.0
aiolyric                         1.0.9
aiomodernforms                   0.1.8
aiomusiccast                     0.14.8
aionanoleaf                      0.2.1
aionotion                        2023.5.1
aiooncue                         0.3.4
aioopenexchangerates             0.4.0
aiopulse                         0.4.3
aiopurpleair                     2022.12.1
aiopvapi                         2.0.4
aiopvpc                          4.1.0
aiopyarr                         23.4.0
aioqsw                           0.3.2
aiorecollect                     1.0.8
aioridwell                       2023.1.0
aiorun                           2022.11.1
aioruuvigateway                  0.1.0
aiosenseme                       0.6.1
aiosenz                          1.0.0
aioserial                        1.3.0
aioshelly                        5.3.2
aioshutil                        1.3
aiosignal                        1.3.1
aioskybell                       22.7.0
aioslimproto                     2.1.1
AIOSomecomfort                   0.0.14
aiosqlite                        0.19.0
aiosteamist                      0.3.2
aioswitcher                      3.3.0
aiosyncthing                     0.5.1
aiotractive                      0.5.5
aiounifi                         47
aiovlc                           0.1.0
aiowatttime                      0.1.1
aiowebostv                       0.3.3
aioymaps                         1.2.2
airly                            1.1.0
airthings-ble                    0.5.3
airthings-cloud                  0.1.0
airtouch4pyapi                   1.0.5
alarmdecoder                     1.13.11
amberelectric                    1.0.4
Ambiclimate                      0.2.1
android-backup                   0.2.0
androidtv                        0.0.70
androidtvremote2                 0.0.8
anova-wifi                       0.10.0
anthemav                         1.4.1
anyio                            3.6.2
apcaccess                        0.0.13
appdirs                          1.4.4
apprise                          1.3.0
aprslib                          0.7.0
APScheduler                      3.6.3
aqipy-atmotech                   0.1.5
aranet4                          2.1.3
arcam-fmj                        1.3.0
arrow                            1.2.3
asn1                             2.7.0
astral                           2.2
astroid                          2.15.4
async-modbus                     0.2.1
async-timeout                    4.0.2
async-upnp-client                0.33.1
asyncclick                       8.1.3.4
asynccmd                         0.2.4
asyncio-dgram                    2.1.2
asyncio-mqtt                     0.16.1
asyncio-throttle                 1.0.2
asyncsleepiq                     1.3.5
asyncssh                         2.13.1
asyncstdlib                      3.10.6
asynctest                        0.13.0
atomicwrites-homeassistant       1.4.1
attrs                            22.2.0
auroranoaa                       0.0.3
aurorapy                         0.2.7
Authlib                          0.15.6
autocommand                      2.2.2
awesomeversion                   22.9.0
axis                             48
azure-core                       1.26.4
azure-eventhub                   5.11.1
backoff                          2.2.1
bandit                           1.7.4
base36                           0.1.1
bcrypt                           4.0.1
beautifulsoup4                   4.11.1
bellows                          0.35.2
bidict                           0.22.1
bimmer-connected                 0.13.3
bitarray                         2.7.3
bitstring                        4.0.2
bitstruct                        8.17.0
black                            23.3.0
bleak                            0.20.2
bleak-retry-connector            3.0.2
blebox-uniapi                    2.1.4
blinker                          1.6.2
blinkpy                          0.19.2
bluemaestro-ble                  0.2.3
bluetooth-adapters               0.15.3
bluetooth-auto-recovery          1.0.3
bluetooth-data-tools             0.4.0
bluetooth-sensor-state-data      1.6.1
bond-async                       0.1.23
boschshcpy                       0.2.35
boto3                            1.20.24
botocore                         1.23.24
broadlink                        0.18.3
brother                          2.3.0
Brotli                           1.0.9
brottsplatskartan                0.0.1
brunt                            1.2.0
bs4                              0.0.1
bthome-ble                       2.9.0
btsocket                         0.2.0
buienradar                       1.0.5
bx-py-utils                      80
cachetools                       5.3.0
caldav                           1.2.0
casttube                         0.2.1
cbor2                            5.4.6
certifi                          2022.12.7
cffi                             1.15.1
cfgv                             3.3.1
chacha20poly1305                 0.0.3
chacha20poly1305-reuseable       0.2.2
charset-normalizer               3.1.0
ciso8601                         2.3.0
click                            8.1.3
click-log                        0.4.0
CO2Signal                        0.4.2
codespell                        2.2.2
coinbase                         2.1.0
colorama                         0.4.6
colored                          1.4.4
coloredlogs                      15.0.1
colorlog                         6.6.0
colorthief                       0.2.1
colorzero                        2.0
colour                           0.1.5
commentjson                      0.9.0
commonmark                       0.9.1
config                           0.5.1
connio                           0.2.0
construct                        2.10.56
convertdate                      2.4.0
coverage                         7.2.4
crccheck                         1.3.0
crcmod                           1.7
croniter                         1.0.6
crownstone-cloud                 1.4.9
crownstone-core                  3.2.1
crownstone-sse                   2.0.4
crownstone-uart                  2.1.0
cryptography                     40.0.2
cssselect                        1.2.0
Cython                           0.29.34
dacite                           1.8.0
datadog                          0.15.0
datapoint                        0.9.8
dateparser                       1.1.8
dbus-fast                        1.85.0
debugpy                          1.6.7
decorator                        5.1.1
deepdiff                         6.3.0
deepmerge                        1.1.0
defusedxml                       0.7.1
deluge-client                    1.7.1
demetriek                        0.4.0
demjson3                         3.0.6
denonavr                         0.11.2
Deprecated                       1.2.13
devolo-home-control-api          0.18.2
devolo-plc-api                   1.2.0
dicttoxml                        1.7.16
dicttoxml2                       2.1.0
dill                             0.3.6
directv                          0.4.0
discovery30303                   0.2.1
distlib                          0.3.6
dnspython                        2.3.0
docopt                           0.6.2
DoorBirdPy                       2.1.0
dsmr-parser                      0.33
DTLSSocket                       0.1.14
dwdwfsapi                        1.0.6
dynalite-devices                 0.1.47
eagle100                         0.1.1
easyenergy                       0.3.0
ecdsa                            0.18.0
elgato                           4.0.1
elkm1-lib                        2.2.2
elmax-api                        0.0.4
emoji                            2.2.0
emulated-roku                    0.2.1
energyflip-client                0.2.2
energyzero                       0.4.1
enocean                          0.50.0
enum-compat                      0.0.3
env-canada                       0.5.34
envoy-reader                     0.20.1
envoy-utils                      0.0.1
envs                             1.4
ephem                            4.1.2
epson-projector                  0.5.0
esphome-dashboard-api            1.2.3
eufylife-ble-client              0.1.7
Events                           0.4
exceptiongroup                   1.1.1
execnet                          1.9.0
faadelays                        0.0.7
faust-cchardet                   2.1.18
feedparser                       6.0.10
ffmpeg                           1.4
file-read-backwards              2.0.0
filelock                         3.11.0
fivem-api                        0.1.2
fjaraskupan                      2.2.0
Flask                            2.3.2
flipr-api                        1.5.0
flux-led                         0.28.37
fnv-hash-fast                    0.3.1
fnvhash                          0.1.0
foobot-async                     1.0.0
forecast-solar                   3.0.0
freebox-api                      1.1.0
freezegun                        1.2.2
fritzconnection                  1.12.0
frozenlist                       1.3.3
future                           0.18.3
gassist-text                     0.0.10
gcal-sync                        4.1.4
gehomesdk                        0.5.7
geocachingapi                    0.2.1
geographiclib                    2.0
geojson                          2.5.0
geopy                            2.3.0
georss-client                    0.15
georss-generic-client            0.6
georss-ign-sismologia-client     0.6
georss-qld-bushfire-alert-client 0.5
get-mac                          0.9.2
getmac                           0.8.2
gios                             3.1.0
gitdb                            4.0.10
GitPython                        3.1.31
glances-api                      0.4.1
goalzero                         0.2.1
goodwe                           0.2.31
google-api-core                  2.11.0
google-api-python-client         2.71.0
google-auth                      2.18.0
google-auth-httplib2             0.1.0
google-auth-oauthlib             1.0.0
google-cloud-pubsub              2.13.11
google-nest-sdm                  2.2.4
googleapis-common-protos         1.59.0
googlemaps                       2.5.1
govee-ble                        0.23.0
gpiozero                         1.6.2
gql                              3.4.1
graphql-core                     3.2.3
graphviz                         0.20.1
greeclimate                      1.4.1
greeneye-monitor                 3.0.3
greenlet                         2.0.2
gridnet                          4.2.0
growattServer                    1.3.0
grpc-google-iam-v1               0.12.6
grpcio                           1.51.1
grpcio-reflection                1.51.1
grpcio-status                    1.51.1
gspread                          5.5.0
gTTS                             2.2.4
guppy3                           3.1.2
h11                              0.14.0
h2                               4.1.0
ha-av                            10.0.0
ha-ffmpeg                        3.1.0
ha-philipsjs                     3.0.0
habitipy                         0.2.0
HAP-python                       4.6.0
hass-nabucasa                    0.66.2
hassil                           1.0.6
HATasmota                        0.6.5
haversine                        2.8.0
hdate                            0.10.4
here-routing                     0.2.0
here-transit                     1.2.0
hijri-converter                  2.2.4
hlk-sw16                         0.0.9
hole                             0.8.0
holidays                         0.21.13
home-assistant-bluetooth         1.10.0
home-assistant-chip-clusters     2023.2.2
home-assistant-frontend          20230428.0
home-assistant-intents           2023.4.26
homeassistant                    2023.5.0.dev0 /home/rlippmann/git/core
homeconnect                      0.7.2
homematicip                      1.0.14
homepluscontrol                  0.0.5
hpack                            4.0.0
html5lib                         1.1
httmock                          1.4.0
http-ece                         1.1.0
httpcore                         0.17.0
httplib2                         0.20.4
httpsig                          1.3.0
httpx                            0.24.0
huawei-lte-api                   1.6.11
humanfriendly                    10.0
humanize                         4.6.0
hyperframe                       6.0.1
hyperion-py                      0.7.5
iaqualink                        0.5.0
ibeacon-ble                      1.0.1
ical                             4.5.1
icalendar                        5.0.5
icmplib                          3.0
identify                         2.5.22
idna                             3.4
ifaddr                           0.1.7
imageio                          2.28.1
importlib-metadata               6.6.0
importlib-resources              5.12.0
incremental                      22.10.0
inflect                          6.0.4
inflection                       0.5.1
influxdb                         5.3.1
influxdb-client                  1.24.0
iniconfig                        2.0.0
inkbird-ble                      0.5.6
insteon-frontend-home-assistant  0.3.5
intelhex                         2.3.0
intellifire4py                   2.2.2
iotawattpy                       0.1.0
ismartgate                       5.0.0
iso4217                          1.11.20220401
isodate                          0.6.1
isort                            5.12.0
itsdangerous                     2.1.2
janus                            1.0.0
jaraco.abode                     3.3.0
jaraco.classes                   3.2.3
jaraco.collections               4.1.0
jaraco.context                   4.3.0
jaraco.email                     3.1.0
jaraco.functools                 3.6.0
jaraco.itertools                 6.2.1
jaraco.logging                   3.1.2
jaraco.net                       9.3.1
jaraco.text                      3.11.1
jeepney                          0.8.0
jellyfin-apiclient-python        1.9.2
Jinja2                           3.1.2
jmespath                         0.10.0
josepy                           1.13.0
jsonpath                         0.82
jsonpickle                       3.0.1
jsonrpc-async                    2.1.1
jsonrpc-base                     2.1.1
jsonrpc-websocket                3.1.4
jsonschema                       4.17.3
justbackoff                      0.6.0
justnimbus                       0.6.0
kafka-python                     2.0.2
kegtron-ble                      0.4.0
keyring                          23.13.1
keyrings.alt                     4.2.0
konnected                        1.2.0
korean-lunar-calendar            0.3.1
krakenex                         2.1.0
lacrosse-view                    1.0.1
lark-parser                      0.7.8
laundrify-aio                    1.1.2
lazy-object-proxy                1.9.0
ld2410-ble                       0.1.1
led-ble                          1.0.0
libpyfoscam                      1.0
librouteros                      3.2.0
libsoundtouch                    0.8.0
life360                          5.5.0
logi-circle                      0.2.3
loguru                           0.7.0
lomond                           0.3.3
lru-dict                         1.1.8
luftdaten                        0.7.4
lxml                             4.9.1
mac-vendor-lookup                0.1.12
magicattr                        0.1.5
Markdown                         3.4.3
MarkupSafe                       2.1.2
marshmallow                      3.19.0
marshmallow-dataclass            8.5.14
maxcube-api                      0.4.3
mbddns                           0.1.2
mccabe                           0.7.0
mcstatus                         6.0.0
meater-python                    0.0.8
mechanize                        0.4.8
mediafile                        0.11.0
melnor-bluetooth                 0.0.20
metar                            1.9.0
meteocalc                        1.1.0
meteofrance-api                  1.2.0
mficlient                        0.3.0
micloud                          0.5
mill-local                       0.2.0
millheater                       0.10.0
miniaudio                        1.56
minio                            7.1.12
moat-ble                         0.1.1
mock                             5.1.0
mock-open                        1.4.0
moehlenhoff-alpha2               1.3.0
mopeka-iot-ble                   0.4.1
more-itertools                   9.1.0
motionblinds                     0.6.17
motioneye-client                 0.3.14
ms-cv                            0.1.1
msgpack                          1.0.5
mullvad-api                      1.0.0
multidict                        6.0.4
munch                            2.5.0
mutagen                          1.46.0
mutesync                         0.0.1
mypy                             1.2.0
mypy-extensions                  1.0.0
natsort                          8.3.1
ndms2-client                     0.1.2
nessclient                       0.10.0
netdisco                         3.0.0
netifaces                        0.11.0
netmap                           0.7.0.2
nettigo-air-monitor              2.1.0
nexia                            2.0.6
nextcloudmonitor                 1.4.0
nextcord                         2.0.0a8
nextdns                          1.4.0
nibe                             2.2.0
nodeenv                          1.7.0
noiseprotocol                    0.3.1
notifications-android-tv         0.1.5
notify-events                    1.0.4
nsw-fuel-api-client              1.1.0
nuheat                           1.0.1
numato-gpio                      0.10.0
numpy                            1.23.2
oauth2client                     4.1.3
oauthlib                         3.2.2
objgraph                         3.5.0
odp-amsterdam                    5.1.0
omnilogic                        0.4.5
ondilo                           0.2.0
onvif-zeep-async                 2.1.1
open-garage                      0.2.0
open-meteo                       0.2.1
openai                           0.27.2
openerz-api                      0.2.0
opuslib                          3.0.1
oralb-ble                        0.17.6
ordered-set                      4.1.0
orjson                           3.8.11
ovoenergy                        1.2.0
p1monitor                        2.1.1
packaging                        23.1
paho-mqtt                        1.6.1
panasonic-viera                  0.3.6
pandas                           1.4.3
path                             16.6.0
pathspec                         0.11.1
pathvalidate                     2.5.2
pbr                              5.11.1
pdunehd                          1.3.2
peco                             0.0.29
pescea                           1.0.12
pexpect                          4.6.0
phone-modem                      0.1.1
pilight                          0.1.1
Pillow                           9.5.0
pip                              22.0.2
pipdeptree                       2.7.0
pkce                             1.0.3
platformdirs                     3.2.0
PlexAPI                          4.13.2
plexauth                         0.0.6
plexwebsocket                    0.0.13
pluggy                           1.0.0
plugwise                         0.31.1
plumbum                          1.8.1
plumlightpad                     0.0.11
ply                              3.11
poolsense                        0.0.8
praw                             7.5.0
prawcore                         2.3.0
prayer-times-calculator          0.0.6
pre-commit                       3.1.0
prettytable                      3.7.0
ProgettiHWSW                     0.1.1
prometheus-client                0.7.1
proto-plus                       1.22.2
protobuf                         4.22.3
psutil                           5.9.4
psutil-home-assistant            0.0.1
ptyprocess                       0.7.0
pubnub                           7.1.0
pure-pcapy3                      1.0.1
pure-python-adb                  0.3.0.dev0
pushbullet.py                    0.11.0
pushover-complete                1.1.1
pvo                              1.0.0
py-canary                        0.5.3
py-cpuinfo                       8.0.0
py-dormakaba-dkey                1.0.4
py-melissa-climate               2.1.4
py-nextbusnext                   0.1.5
py-nightscout                    1.2.2
py-synologydsm-api               2.1.4
py-vapid                         1.9.0
py17track                        2021.12.2
py3rijndael                      0.3.3
pyadtpulse                       1.0.5
pyaehw4a1                        0.3.9
pyaes                            1.6.1
pyairnow                         1.2.1
pyairvisual                      2022.12.1
pyasn1                           0.4.8
pyasn1-modules                   0.3.0
pyatag                           0.3.5.3
pyatmo                           7.5.0
pyatv                            0.10.3
pyaussiebb                       0.0.15
pybalboa                         1.0.1
pyblackbird                      0.6
pybotvac                         0.0.23
pybravia                         0.3.3
pycares                          4.3.0
pyCEC                            0.5.2
pycfdns                          2.0.1
PyChromecast                     13.0.7
pycognito                        2022.12.0
pycomfoconnect                   0.5.1
pyControl4                       1.1.0
pycoolmasternet-async            0.1.5
pycountry                        22.3.5
pycparser                        2.21
pycryptodome                     3.17
pycryptodomex                    3.17
pydaikin                         2.9.0
pydantic                         1.10.7
pydeconz                         111
pydexcom                         0.2.3
pydroid-ipcam                    2.0.0
pyeconet                         0.1.20
pyefergy                         22.1.1
pyEight                          0.3.2
pyeverlights                     0.1.0
pyevilgenius                     2.0.0
pyezviz                          0.2.0.9
pyfibaro                         0.7.1
pyfido                           2.1.2
pyfireservicerota                0.0.43
pyflic                           2.0.3
PyFlick                          0.0.2
PyFlume                          0.6.5
pyforked-daapd                   0.1.14
pyfreedompro                     1.1.0
pyfritzhome                      0.6.8
PyFronius                        0.7.1
pyfttt                           0.3
Pygments                         2.15.1
pygti                            0.9.3
pyhaversion                      22.8.0
pyheos                           0.7.2
pyhiveapi                        0.5.14
pyhomematic                      0.1.77
pyhumps                          3.8.0
pyialarm                         2.2.0
pyicloud                         1.0.0
pyinsteon                        1.4.2
pyipma                           3.0.6
pyipp                            0.12.1
pyiqvia                          2022.4.0
pyiss                            1.0.1
pyisy                            3.1.14
pyjvcprojector                   1.0.6
PyJWT                            2.6.0
pykaleidescape                   1.0.1
pykira                           0.1.1
pykmtronic                       0.3.0
pykodi                           0.2.7
pykoplenti                       1.0.0
pykrakenapi                      0.1.8
pykulersky                       0.5.2
pylast                           5.1.0
pylaunches                       1.4.0
pylibrespot-java                 0.1.1
pylint                           2.17.4
pylint-per-file-ignores          1.1.0
pylitejet                        0.5.0
pylitterbot                      2023.4.0
pylutron-caseta                  0.18.1
pymailgunner                     1.4
pymata-express                   1.19
pymazda                          0.3.8
PyMeeus                          0.5.12
pymelcloud                       2.5.8
PyMetEireann                     2021.8.0
pymeteoclimatic                  0.0.6
PyMetno                          0.9.0
PyMicroBot                       0.0.9
pymochad                         0.2.0
pymodbus                         3.1.3
pymonoprice                      0.4
pymyq                            3.1.4
pymysensors                      0.24.0
PyNaCl                           1.5.0
pynetgear                        0.10.9
PyNINA                           0.3.0
pynobo                           1.6.0
pynuki                           1.6.1
pynut2                           2.1.2
pynws                            1.4.1
pynx584                          0.5
pynzbgetapi                      0.2.0
pyobihai                         1.3.2
pyoctoprintapi                   0.1.11
pyOpenSSL                        23.1.0
pyopenuv                         2023.2.0
pyopnsense                       0.2.0
pyotgw                           2.1.3
pyotp                            2.8.0
pyoverkiz                        1.7.8
pyowm                            3.2.0
pyownet                          0.10.0.post1
pyparsing                        3.0.9
pypck                            0.7.16
pypjlink2                        1.2.1
pyplaato                         0.0.18
pypoint                          2.3.0
pyprof2calltree                  1.4.5
pyprosegur                       0.0.9
pyprusalink                      1.1.0
pyps4-2ndscreen                  1.3.1
Pypubsub                         4.0.3
PyQRCode                         1.2.1
pyquery                          2.0.0
pyqwikswitch                     0.93
pyrainbird                       2.0.0
pyRFC3339                        1.1
pyRFXtrx                         0.30.1
PyRIC                            0.1.6.3
pyrisco                          0.5.7
pyrituals                        0.0.6
PyRMVtransport                   0.3.3
pyroute2                         0.7.5
pyrsistent                       0.19.3
pyruckus                         0.16
pyrympro                         0.0.7
pysabnzbd                        1.1.1
pysensibo                        1.0.28
pyserial                         3.5
pyserial-asyncio                 0.6
pysiaalarm                       3.1.1
pysignalclirestapi               0.3.18
pysma                            0.7.3
pysmappee                        0.2.29
pysmartapp                       0.3.3
pysmartthings                    0.7.6
pysmb                            1.2.9.1
pysml                            0.0.10
pysnmp-pyasn1                    1.1.3
pysnmp-pysmi                     1.1.10
pysnmplib                        5.0.21
pysnooz                          0.8.3
PySocks                          1.7.1
pysoma                           0.0.12
pyspcwebgw                       0.4.0
pysqueezebox                     0.6.1
pyswitchbee                      1.7.19
PySwitchbot                      0.37.6
PySyncThru                       0.7.10
pytankerkoenig                   0.0.6
pytautulli                       23.1.1
pytest                           7.3.1
pytest-aiohttp                   1.0.4
pytest-asyncio                   0.20.3
pytest-cov                       3.0.0
pytest_freezer                   0.4.6
pytest-picked                    0.4.6
pytest-runner                    6.0.0
pytest-socket                    0.5.1
pytest-sugar                     0.9.6
pytest-test-groups               1.0.3
pytest-timeout                   2.1.0
pytest-unordered                 0.5.2
pytest-xdist                     3.2.1
python-awair                     0.2.4
python-bsblan                    0.5.11
python-dateutil                  2.8.2
python-didl-lite                 1.3.2
python-ecobee-api                0.2.14
python-engineio                  3.14.2
python-fullykiosk                0.0.12
python-homewizard-energy         2.0.1
python-izone                     1.2.9
python-jose                      3.3.0
python-juicenet                  1.1.0
python-kasa                      0.5.1
python-magic                     0.4.27
python-matter-server             3.2.0
python-miio                      0.5.12
python-nest                      4.2.0
python-otbr-api                  1.0.9
python-picnic-api                1.1.0
python-qbittorrent               0.4.2
python-roborock                  0.8.3
python-slugify                   4.0.1
python-smarttub                  0.0.33
python-socketio                  4.6.1
python-songpal                   0.15.2
python-tado                      0.12.0
python-telegram-bot              13.1
pyTibber                         0.27.2
pytile                           2023.4.0
pytomorrowio                     0.3.5
pytraccar                        1.0.0
pytradfri                        9.0.1
pytrafikverket                   0.3.3
PyTransportNSW                   0.1.1
PyTurboJPEG                      1.6.7
pytz                             2023.3
pytz-deprecation-shim            0.1.0.post0
pyudev                           0.23.2
pyunifiprotect                   4.8.3
pyuptimerobot                    22.2.0
pyusb                            1.2.1
pyvera                           0.3.13
pyvesync                         2.1.1
PyViCare                         2.25.0
pyvizio                          0.1.61
pyvolumio                        0.1.5
pyW215                           0.7.0
pywebpush                        1.9.2
pywemo                           0.9.1
pywilight                        0.0.74
pywizlight                       0.5.14
pyws66i                          1.1
PyXiaomiGateway                  0.14.3
PyYAML                           6.0
pyzerproc                        0.4.8
qingping-ble                     0.8.2
RachioPy                         1.0.3
radios                           0.1.1
radiotherm                       2.1.0
rapt-ble                         0.1.0
ratelimit                        2.2.1
recurring-ical-events            2.0.2
redis                            4.5.4
regenmaschine                    2022.11.0
regex                            2021.8.28
related                          0.7.3
renault-api                      0.1.13
reolink-aio                      0.5.13
requests                         2.29.0
requests-file                    1.5.1
requests-futures                 1.0.0
requests-mock                    1.10.0
requests-oauth                   0.4.1
requests-oauthlib                1.3.1
requests-toolbelt                0.10.1
respx                            0.20.1
RestrictedPython                 6.0
retry2                           0.9.5
rflink                           0.0.65
rich                             10.16.2
ring-doorbell                    0.7.2
rokuecp                          0.17.1
roombapy                         1.6.8
roonapi                          0.1.4
rpi-bad-power                    0.1.0
rsa                              4.9
RtmAPI                           0.7.2
rtsp-to-webrtc                   0.5.1
ruff                             0.0.262
ruuvitag-ble                     0.1.1
Rx                               3.2.0
rxv                              0.7.0
s3transfer                       0.5.2
samsungctl                       0.7.1
samsungtvws                      2.5.0
scapy                            2.5.0
schedule                         1.2.0
screenlogicpy                    0.8.2
SecretStorage                    3.3.3
securetar                        2023.3.0
semver                           3.0.0
sense-energy                     0.11.2
sensirion-ble                    0.0.1
sensor-state-data                2.14.0
sensorpro-ble                    0.5.3
sensorpush-ble                   1.5.5
sentry-sdk                       1.21.0
serialio                         2.4.0
setuptools                       59.6.0
sfrbox-api                       0.0.6
sgmllib3k                        1.0.0
sharkiq                          1.0.2
shellingham                      1.5.0.post1
simplehound                      0.3
simplejson                       3.19.1
simplepush                       2.1.1
simplisafe-python                2023.4.0
siobrultech-protocols            0.5.0
six                              1.16.0
slackclient                      2.5.0
slixmpp                          1.7.1
smart-meter-texas                0.4.7
smhi-pkg                         1.0.16
smmap                            5.0.0
snapcast                         2.3.2
sniffio                          1.3.0
snitun                           0.35.0
sockio                           0.15.0
soco                             0.29.1
solaredge                        0.0.2
solax                            0.3.0
somfy-mylink-synergy             1.0.6
sonos-websocket                  0.1.1
soupsieve                        2.4
speak2mary                       1.4.0
speedtest-cli                    2.1.3
spiderpy                         1.6.1
spotipy                          2.23.0
SQLAlchemy                       2.0.11
srpenergy                        1.3.6
srptools                         1.0.1
sseclient-py                     1.7.2
starline                         0.1.5
starlink-grpc-core               1.1.1
statsd                           3.2.1
stdiomask                        0.0.6
steamodd                         4.21
stevedore                        5.0.0
stookalert                       0.1.4
stookwijzer                      1.3.0
stringcase                       1.2.0
subarulink                       0.7.6
sunwatcher                       0.2.1
surepy                           0.8.0
syrupy                           4.0.2
systembridgeconnector            3.4.8
tabulate                         0.9.0
tailer                           0.4.1
tailscale                        0.2.0
tellduslive                      0.10.11
temescal                         0.5
temperusb                        1.6.0
tempora                          5.2.2
tenacity                         8.2.2
termcolor                        2.2.0
tesla-powerwall                  0.3.19
tesla-wall-connector             1.0.2
text-unidecode                   1.3
thermobeacon-ble                 0.6.0
thermopro-ble                    0.4.5
tilt-ble                         0.2.3
titlecase                        2.4
todoist-api-python               2.0.2
tololib                          0.1.0b4
tomli                            2.0.1
tomlkit                          0.11.7
toonapi                          0.2.1
tornado                          6.3.1
total-connect-client             2023.2
tplink_omada_client              1.2.4
tqdm                             4.64.0
transitions                      0.8.11
transmission-rpc                 4.1.5
ttls                             1.5.1
tuya-iot-py-sdk                  0.6.6
twentemilieu                     1.0.0
twilio                           6.32.0
twitchAPI                        2.5.2
typer                            0.7.0
types-atomicwrites               1.4.1
types-backports                  0.1.3
types-beautifulsoup4             4.12.0.6
types-chardet                    0.1.5
types-croniter                   1.0.6
types-decorator                  5.1.1
types-enum34                     1.1.8
types-html5lib                   1.1.11.15
types-ipaddress                  1.0.8
types-mock                       5.1.0.2
types-paho-mqtt                  1.6.0.1
types-pkg-resources              0.1.3
types-python-dateutil            2.8.19.5
types-python-slugify             0.1.2
types-pytz                       2022.7.0.0
types-PyYAML                     6.0.12.2
types-requests                   2.29.0.0
types-toml                       0.10.8.1
types-urllib3                    1.26.25.10
typing_extensions                4.5.0
typing-inspect                   0.8.0
tzdata                           2023.3
tzlocal                          4.3
uasiren                          0.0.1
ulid-transform                   0.6.3
ultraheat-api                    0.5.1
uModbus                          1.0.4
unasync                          0.5.0
unifi-discovery                  1.1.7
uonet-request-signer-hebe        0.1.1
upb-lib                          0.5.3
upcloud-api                      2.0.0
update-checker                   0.18.0
uritemplate                      4.1.1
url-normalize                    1.4.3
urllib3                          1.26.15
usb-devices                      0.4.1
uvcclient                        0.11.0
uvloop                           0.17.0
vallox-websocket-api             3.2.1
vehicle                          1.0.0
velbus-aio                       2023.2.0
venstarcolortouch                0.19
vilfo-api-client                 0.3.2
vincenty                         0.1.4
virtualenv                       20.21.0
vobject                          0.9.6.1
voip-utils                       0.0.7
vol                              0.1.1
voluptuous                       0.13.1
voluptuous-serialize             2.6.0
volvooncall                      0.10.2
vsure                            2.6.1
vulcan-api                       2.3.0
vultr                            0.1.2
wakeonlan                        2.1.0
wallbox                          0.4.12
warrant-lite                     1.0.4
watchdog                         2.3.1
WazeRouteCalculator              0.14
wcwidth                          0.2.6
webcolors                        1.13
webencodings                     0.5.1
webrtcvad                        2.0.10
websocket-client                 1.5.1
websockets                       11.0.2
Werkzeug                         2.3.4
wheel                            0.40.0
whirlpool-sixth-sense            0.18.3
whois                            0.9.27
wiffi                            1.1.2
withings-api                     2.4.0
wled                             0.16.0
wolf-smartset                    0.1.11
wrapt                            1.15.0
WSDiscovery                      2.0.0
wyoming                          0.0.1
x-wr-timezone                    0.0.5
xbox-webapi                      2.0.11
xiaomi-ble                       0.17.0
xknx                             2.9.0
xmltodict                        0.13.0
yagrc                            1.1.1
yalesmartalarmclient             0.3.9
yalexs                           1.3.3
yalexs-ble                       2.1.16
yamllint                         1.28.0
yarl                             1.9.2
yeelight                         0.7.10
yolink-api                       0.2.8
youless-api                      1.0.1
zamg                             0.2.2
zeep                             4.2.1
zeroconf                         0.58.2
zeversolar                       0.3.1
zha-quirks                       0.0.99
zigpy                            0.55.0
zigpy-deconz                     0.21.0
zigpy-xbee                       0.18.0
zigpy-zigate                     0.11.0
zigpy-znp                        0.11.1
zipp                             3.15.0
zwave-js-server-python           0.48.0
zwave-me-ws                      0.4.2
rchiodo commented 10 months ago

Thanks. I installed everything in that list except for your custom build of homeassistant (which looked like it was pointing to your custom build).

Here's the requirements.txt I used. requirements.txt

I cannot reproduce with a simple project with that requirements.txt installed. So maybe it's your homeassistant build, or maybe it's something in the project intersecting with the other things in the venv.

Can you try installing the requirements.txt into a fresh venv and see if it reproduces?

TheCaptainCat commented 9 months ago

I have the same issue. Pylance 2023.9.10 reports warning on perfectly valid code while 2023.8.50 works as expected.

I have this kind of errors on @staticmethod

Argument of type "(c1: Cache, c2: Cache) -> Cache" cannot be assigned to parameter "__f" of type "() -> _R_co@staticmethod" in function "__init__"
  Type "(c1: Cache, c2: Cache) -> Cache" cannot be assigned to type "() -> _R_co@staticmethod"

Also these errors on list element access

Argument of type "Literal[-1]" cannot be assigned to parameter "__s" of type "slice" in function "__getitem__"
  "Literal[-1]" is incompatible with "slice"

pathlib.Path.cwd() raises a warning Type of "cwd" is partially unknown Type of "cwd" is "() -> Unknown" since @classmethod in pathlib.py also raises the same error as @staticmethod in my code.

I don't have standard diagnostics overrides, here they are:

{
  "python.analysis.diagnosticSeverityOverrides": {
    "reportAssertAlwaysTrue": "warning",
    "reportCallInDefaultInitializer": "none",
    "reportConstantRedefinition": "warning",
    "reportDeprecated": "warning",
    "reportDuplicateImport": "warning",
    "reportFunctionMemberAccess": "warning",
    "reportGeneralTypeIssues": "error",
    "reportImplicitOverride": "warning",
    "reportImplicitStringConcatenation": "none",
    "reportImportCycles": "none",
    "reportIncompatibleMethodOverride": "error",
    "reportIncompatibleVariableOverride": "error",
    "reportIncompleteStub": "warning",
    "reportInconsistentConstructor": "warning",
    "reportInvalidStringEscapeSequence": "error",
    "reportInvalidStubStatement": "error",
    "reportInvalidTypeVarUse": "warning",
    "reportMatchNotExhaustive": "warning",
    "reportMissingImports": "error",
    "reportMissingModuleSource": "error",
    "reportMissingParameterType": "warning",
    "reportMissingSuperCall": "none",
    "reportMissingTypeArgument": "warning",
    "reportMissingTypeStubs": "warning",
    "reportOptionalCall": "warning",
    "reportOptionalContextManager": "warning",
    "reportOptionalIterable": "warning",
    "reportOptionalMemberAccess": "warning",
    "reportOptionalOperand": "warning",
    "reportOptionalSubscript": "warning",
    "reportOverlappingOverload": "warning",
    "reportPrivateImportUsage": "warning",
    "reportPrivateUsage": "warning",
    "reportPropertyTypeMismatch": "error",
    "reportSelfClsParameterName": "warning",
    "reportShadowedImports": "warning",
    "reportTypeCommentUsage": "warning",
    "reportTypedDictNotRequiredAccess": "error",
    "reportUnboundVariable": "error",
    "reportUndefinedVariable": "error",
    "reportUninitializedInstanceVariable": "none",
    "reportUnknownArgumentType": "warning",
    "reportUnknownLambdaType": "none",
    "reportUnknownMemberType": "warning",
    "reportUnknownParameterType": "warning",
    "reportUnknownVariableType": "warning",
    "reportUnnecessaryCast": "warning",
    "reportUnnecessaryComparison": "warning",
    "reportUnnecessaryContains": "warning",
    "reportUnnecessaryIsInstance": "warning",
    "reportUnnecessaryTypeIgnoreComment": "warning",
    "reportUnsupportedDunderAll": "warning",
    "reportUntypedBaseClass": "warning",
    "reportUntypedClassDecorator": "warning",
    "reportUntypedFunctionDecorator": "warning",
    "reportUntypedNamedTuple": "warning",
    "reportUnusedCallResult": "none",
    "reportUnusedClass": "warning",
    "reportUnusedCoroutine": "error",
    "reportUnusedExpression": "warning",
    "reportUnusedFunction": "warning",
    "reportUnusedImport": "warning",
    "reportUnusedVariable": "warning",
    "reportWildcardImportFromLibrary": "warning"
  }
}

And here is my requirements.txt:

aiohttp==3.8.5
aiosqlite==0.19.0
autopep8==2.0.2
asyncpg==0.28.0
autoflake==2.2.0
coverage==7.3.0
black==23.7.0
flake8==6.1.0
isort==5.12.0
mypy==1.5.1
pytest==7.4.0
pytest-aiohttp==1.0.4
pytest-asyncio==0.21.1
pytest-cov==4.1.0
pyyaml==6.0.1
ruff==0.0.284
SQLAlchemy==2.0.20
typing_extensions==4.7.1
twine==4.0.2

In the meantime, i'm sticking to 2023.8.50.

erictraut commented 9 months ago

@TheCaptainCat, I'm guessing that if you create a new venv and populate it with these requirements, the problem will go away. Could you test that hypothesis? I just tried to repro your issue with the above requirements.txt dependencies, and I wasn't able to.

If my theory is correct, then there's something else in your current venv (perhaps some corruption) that is triggering this behavior in pylance, and it would be good to understand what that is.

TheCaptainCat commented 9 months ago

@erictraut, I tried a new venv, even tried clearing the WSL server cache. But that didn't work. I'll try setting everything up on another system and I'll get back here.

TheCaptainCat commented 9 months ago

@erictraut So you were right, I installed a fresh Fedora and reinstalled all requirements and VS extensions just like my regular setup and everything works as intended.

So it seems to be a bad cache, but does someone knows how to completely clear that cache. I use vscode-insiders on WSL.

I must add that Pylance had become extremely slow and was re-analysing every file in the project on every keystroke, making work very slow and frustrating. That seems to be gone too with a fresh install.

rchiodo commented 9 months ago

Something weird is going on. This sounds similar to this issue: https://github.com/microsoft/pylance-release/issues/4889

stevesimmons commented 9 months ago

For the last three weeks, I've been getting the same issue on staticmethod and classmethod and on some list operations. This is on old code that type-checked correctly for months. The type diagnostics in Pylance's messages match those in this issue and the couple of other related ones.

Here is a minimal example to reproduce:

class MyClass:
    @classmethod    # Pylance gives red squiggle under "classmethod"
    def hello(cls):
        print("hello")

I have tried reinstalling the Pylance VSC extension and switching to prerelease. Not tried reinstalling venv yet.

stevesimmons commented 9 months ago

Update: Appears to be fixed on reinstalling the venv

av1m commented 9 months ago

I had the exact same problem @stevesimmons I confirm, I have just reinstalled venv and the dependencies, I no longer have these errors.

rchiodo commented 9 months ago

Closing given that the fix is to reinstall your venv. Something may have been installing something that was interfering with our type stubs, but is no longer installing those extra bits.

If somebody can reproduce this with a fresh venv, please add a comment with directions on installing. Thanks.