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

Forbid properties with parameters #698

Closed
sobolevn opened this issue Jul 21, 2019 · 3 comments
Closed

Forbid properties with parameters #698

sobolevn opened this issue Jul 21, 2019 · 3 comments
Labels
help wanted Extra attention is needed level:starter Good for newcomers rule request Adding a new rule

Comments

@sobolevn
Copy link
Member

Rule request

Thesis

Code like this:

class Test(object):
    @property
    def b(self, arg):
        return 1

Should be forbidden. Since this class definition is incorrect.
.b won't work at all.

Reasoning

This is OOP rule that checks that properties are defined correctly.

@sobolevn sobolevn added help wanted Extra attention is needed level:starter Good for newcomers rule request Adding a new rule labels Jul 21, 2019
@sobolevn sobolevn added this to the Version 0.12.0 milestone Jul 21, 2019
@sobolevn
Copy link
Member Author

sobolevn commented Jul 21, 2019

We should use @property and @abc.abstractbaseproperty as decorators.

@sobolevn
Copy link
Member Author

mypy also catches this:

class Test:
    @property
    def test(self, abc):
        return 1

Test().test

Returns:

» mypy ex.py
ex.py:3: error: Too many arguments

@sobolevn
Copy link
Member Author

We do not assume or check types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed level:starter Good for newcomers rule request Adding a new rule
Projects
None yet
Development

No branches or pull requests

1 participant