如何使 VS 代码 IntelliSense 仅显示 class 属性而不显示内置对象属性?

How to make VS code IntelliSense to show class only attributes not the built object attributes?

我有一个 python class,我只想在智能感知建议中看到 class 属性。

class car():
    def __init__(self, brand, model, year):
        self.brand = brand
        self.model = model
        self.year = year


c1 = car()

当我使用“c1”时。我看到像“__ dir__”、“__ getattribute__”等结果。但我只想在智能感知建议中看到“品牌”、“型号”和“年份”。

有什么可以覆盖此行为吗?

之所以显示“__dir__”,“__getattribute__”是代码中使用的“__init__”方法,来自文件“[=11” =]",这个文件还包括"__dir__","__getattribute__":

解决方法:比如关闭“__dir__”:(将“builtins.pyi”中的“def __dir__(self) -> Iterable[str]: ...”注释掉)

之前:

之后:

更新:

我试过依次关闭其他显示器,以下是我在“builtins.pyi”中注释的代码:

只剩下四个选项:(因为这个文件定义了它们)

但是为了避免影响代码的使用,不建议大家更改这个文件。并且这不影响提示内容“品牌”、“型号”、“年份”作为第一个显示:(我用小框的时候会显示偏好,保留。)