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

Remove #type: comments for attributes. #16

Open
ssbr opened this issue Oct 27, 2020 · 0 comments
Open

Remove #type: comments for attributes. #16

ssbr opened this issue Oct 27, 2020 · 0 comments

Comments

@ssbr
Copy link
Owner

ssbr commented Oct 27, 2020

A lot of classes in refex predate the attrs type argument, so that they look like this:

@attr.s(...)
class Foo(...)
  x = attr.ib(...)  # type: SomeTypeHere

The new form is:

@attr.s(...)
class Foo(...)
  x = attr.ib(..., type=SomeTypeHere)

Benefits of the new form:

  1. shows up in documentation.
  2. better-supported by tools
  3. formats way better when you need to break across lines etc.

It might be a neat thing to do to, well, automate this via refex and apply it to refex itself. ;) It's a nontrivial matcher, because it involves editing (removing) a comment and editing the arguments to a function, which makes it useful as a demonstration of how to do nontrivial things with Refex. Since pretty much the only time anyone wants to use Refex is when it's something nontrivial, well...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant