Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
gh-112205: Support @setter annotation from AC#112922
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
488a127384d6c12a8c3de0ffa78b8e85ab3f3517f9323cfc030da0cf1539d11d18cd49bc373f60cd047bc8a035f9c6696106b1cb12510a3553777df61f7215File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -2197,6 +2197,58 @@ class Foo "" "" | ||
| expected_error = err_template.format(invalid_kind) | ||
| self.expect_failure(block, expected_error, lineno=3) | ||
| def test_invalid_getset(self): | ||
| annotations = ["@getter", "@setter"] | ||
| for annotation in annotations: | ||
| with self.subTest(annotation=annotation): | ||
| block = f""" | ||
| module foo | ||
| class Foo "" "" | ||
| {annotation} | ||
| Foo.property -> int | ||
| """ | ||
| expected_error = f"{annotation} method cannot define a return type" | ||
| self.expect_failure(block, expected_error, lineno=3) | ||
| block = f""" | ||
| module foo | ||
| class Foo "" "" | ||
| {annotation} | ||
| Foo.property | ||
| obj: int | ||
| / | ||
| """ | ||
| expected_error = f"{annotation} method cannot define parameters" | ||
| self.expect_failure(block, expected_error) | ||
| def test_duplicate_getset(self): | ||
| annotations = ["@getter", "@setter"] | ||
| for annotation in annotations: | ||
| with self.subTest(annotation=annotation): | ||
| block = f""" | ||
| module foo | ||
| class Foo "" "" | ||
| {annotation} | ||
| {annotation} | ||
| Foo.property -> int | ||
| """ | ||
| expected_error = f"Cannot apply{annotation} twice to the same function!" | ||
| self.expect_failure(block, expected_error, lineno=3) | ||
| def test_getter_and_setter_disallowed_on_same_function(self): | ||
| dup_annotations = [("@getter", "@setter"), ("@setter", "@getter")] | ||
corona10 marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading. Please reload this page. | ||
| for dup in dup_annotations: | ||
| with self.subTest(dup=dup): | ||
| block = f""" | ||
| module foo | ||
| class Foo "" "" | ||
| {dup[0]} | ||
| {dup[1]} | ||
| Foo.property -> int | ||
| """ | ||
| expected_error = "Cannot apply both @getter and @setter to the same function!" | ||
| self.expect_failure(block, expected_error, lineno=3) | ||
| def test_duplicate_coexist(self): | ||
| err = "Called @coexist twice" | ||
| block = """ | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.