pylance-release
pylance-release copied to clipboard
There are still some deficiencies in automatic completion
Environment data
- Language Server version: Pylance async client (2024.3.2) started with python extension (2024.2.1)
- OS and version: Ubuntu 20.04
- Python version (& distribution if applicable, e.g. Anaconda): 3.8.10
Code Snippet
Repro Steps
- I want inherit a airflow class under
airflow/sensor/filesystem.pywhich has init like this
class FileSensor(BaseSensorOperator):
........
def __init__(
self,
*,
filepath, fs_conn_id="fs_default",
recursive=False,
deferrable: bool = conf.getboolean("operators", "default_deferrable", fallback=False),
**kwargs,
):
...........
and i auto-complete init, and expected it will be this
class _FileSensor(FileSensor):
........
def __init__(
self,
*,
filepath, fs_conn_id="fs_default",
recursive=False,
deferrable: bool = conf.getboolean("operators", "default_deferrable", fallback=False),
**kwargs,
):
...........
but it is this
class _FileSensor(FileSensor):
........
def __init__(
self,
*,
filepath, fs_conn_id="fs_default",
recursive=False,
deferrable: bool = ...,
**kwargs,
):
...........
default value of deferrable becomes '...'. i don't know if it is any grammar sugar of python, but airflow can not parse this in dag, and in my local interactive python the default value of deferrable in my subclass _FileSenor has been replaced by Ellipsis.
i found a similar issue #3374 and it looks like fixed. I don't know if this similar case depends on the default value inherited or it is an expected behavior, but it really bother me.
it works as expected for me. what version of pylance are you using? can you try latest pylance?
also, it looks like you have misspelling in class _FileSensor(FileSenor):.
it works as expected for me. what version of pylance are you using? can you try latest pylance?
also, it looks like you have misspelling in
class _FileSensor(FileSenor):.
should i check the version in the side bar of Extensions?or in any other way? In the side bar, it shows v2024.3.2, and i didn't see a newer version. And in this version, I come across the same question once again after retry.
Can you indicate the misspelling more clearly? i didn't find it, but i'm really sorry for this.
our latest version is 2023.6.1, you might not seeing it because your vscode or python extension are old and newer version doesn't support those versions you have anymore, can you check what versions of vscode and python extensions? and make sure you are on the latest versions?
and misspelling is
class FileSensor(BaseSensorOperator): it says FileSensor but class _FileSensor(FileSenor) says FileSenor which is missing s
our latest version is
2023.6.1, you might not seeing it because yourvscodeorpython extensionare old and newer version doesn't support those versions you have anymore, can you check what versions ofvscodeandpython extensions? and make sure you are on the latest versions?and misspelling is
class FileSensor(BaseSensorOperator):it saysFileSensorbutclass _FileSensor(FileSenor)saysFileSenorwhich is missings
Do you mean 2024.6.1? My vscode version is 1.83.1 and pylance is v2024.3.2.
Thanks for your pointing, i have fixed the misspelling.
ah, sorry, ya, 2024.6.1
@WiC-htao not sure what the gif is trying to tell. can you provide a bit more detail?
I believe it's the original complaint?
The deferrable parameter isn't matching what the original code did.
It ends up like this:
deferrable: bool = ...,
when the user wanted this:
deferrable: bool = conf.getboolean("operators", "default_deferrable", fallback=False),
You can repro with this:
from airflow.sensors.filesystem import FileSensor
class MySensor(FileSensor):
def __init__
If you look at the original class, it has this for the __init__
def __init__(
self,
*,
filepath,
fs_conn_id="fs_default",
recursive=False,
deferrable: bool = conf.getboolean("operators", "default_deferrable", fallback=False),
**kwargs,
):
so, looked into code. this is currently by design. if default value expression is not simple expression and if overriding is not happening within the same module as the method it is overriding, then we use "..."
that said, if we just put the expression (and let them show errors such as missing name and etc) then it is easy to support, but if we want to properly do this case, it would be enhancement and a bit more complex to support since we need to figure out how to remove those errors such as adding imports.
- just adding missing imports might be all we need to do. so might be simpler...
so, looked into code. this is currently by design. if default value expression is not simple expression and if overriding is not happening within the same module as the method it is overriding, then we use "..."
that said, if we just put the expression (and let them show errors such as missing name and etc) then it is easy to support, but if we want to properly do this case, it would be enhancement and a bit more complex to support since we need to figure out how to remove those errors such as adding imports.
- just adding missing imports might be all we need to do. so might be simpler...
Got it.
While, i think it is a little not friendly enough, for program will not crash but have unexpected behavior quietly when I don't properly handle '...' . This is not easy to debug, especially when i have too many args to check everyone inherit correctly.