Skip to content

Move rename_transform outside of Query.rename #93

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

Open
orsinium opened this issue Jun 26, 2019 · 3 comments
Open

Move rename_transform outside of Query.rename #93

orsinium opened this issue Jun 26, 2019 · 3 comments

Comments

@orsinium
Copy link

orsinium commented Jun 26, 2019

For example, you want to rename node only if it matches some pattern. You can do this:

def modify(node: LN, capture: Capture, filename: Filename) -> None:
  if re.match(...):
    rename_transform(...)

However, rename_transform isn't available for import. BTW, it's can be really useful to have bowler.modifiers with some common modifiers to reuse them. Maybe, moving rename_transform in it is a good start. Same for add_argument_transform, encapsulate_transform etc

And what if use _modifier instead of _transform?

I can do PR for it if you agree with the point.

@thatch
Copy link
Contributor

thatch commented Jul 3, 2019

That example would make a great filter, would that solve much of the use case?

@orsinium
Copy link
Author

orsinium commented Jul 3, 2019

Filter can cover situation with choosing the right action, but not case with some simple preparation. For example, do relative imports if possible: make relative path if possible and pass it into rename_trfansform, otherwise use absolute import.

@amyreese
Copy link
Contributor

Moving away from closures for these transforms will also be necessary to eventually support Windows (or Py3.8+ on Mac) where multiprocessing uses spawned processes.

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

3 participants