Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stubgen: fix missing property setter in semantic analysis mode #16303

Merged
merged 1 commit into from
Oct 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions mypy/stubgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,7 @@ def process_decorator(self, o: Decorator) -> None:

Only preserve certain special decorators such as @abstractmethod.
"""
o.func.is_overload = False
for decorator in o.original_decorators:
if not isinstance(decorator, (NameExpr, MemberExpr)):
continue
Expand Down
2 changes: 0 additions & 2 deletions mypy/stubutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -669,8 +669,6 @@ def set_defined_names(self, defined_names: set[str]) -> None:
self.add_name(f"{pkg}.{t}", require=False)

def check_undefined_names(self) -> None:
print(self._all_)
print(self._toplevel_names)
Comment on lines -672 to -673
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These spurious prints are not related but they seem to be left here by mistake. They are polluting the stdout.
The blame points to #15770.

undefined_names = [name for name in self._all_ or [] if name not in self._toplevel_names]
if undefined_names:
if self._output:
Expand Down
18 changes: 18 additions & 0 deletions test-data/unit/stubgen.test
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,24 @@ class A:
def f(self, x) -> None: ...
def h(self) -> None: ...

[case testProperty_semanal]
class A:
@property
def f(self):
return 1
@f.setter
def f(self, x): ...

def h(self):
self.f = 1
[out]
class A:
@property
def f(self): ...
@f.setter
def f(self, x) -> None: ...
def h(self) -> None: ...

-- a read/write property is treated the same as an attribute
[case testProperty_inspect]
class A:
Expand Down
Loading