facebookarchive / codemod

Codemod is a tool/library to assist you with large-scale codebase refactors that can be partially automated but still require human oversight and occasional intervention. Codemod was developed at Facebook and released as open source.
Apache License 2.0
4.12k stars 197 forks source link

Query.start_position has no setter #83

Closed astonm closed 7 years ago

astonm commented 8 years ago

If I interrupt my codemod session (with ctrl-C) and attempt to restart it, I get the expected prompt

Resume where you left off, at ./my/files/code.py:10 (y/n)?

But when I choose y I get the following exception:

Traceback (most recent call last):
  File "/usr/local/bin/codemod", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/site-packages/codemod/base.py", line 1004, in main
    run_interactive(**options)
  File "/usr/local/lib/python2.7/site-packages/codemod/base.py", line 130, in run_interactive
    query.start_position = bookmark
AttributeError: can't set attribute

Looking at codemod.py there's a start_position = property(get_start_position), but no setter is specified. I can't find record of a setter having ever been there in this repo, but I know this feature used to work for me in some past version of codemod, so something must have changed. This may be an issue across Python versions (my /usr/bin/env python2 is 2.7.12).

If indeed some code is missing, I'm happy to submit a PR to add (re-add?) a setter for Query.start_position, and also one for Query.end_position while I'm at it.

modocache commented 8 years ago

Yes, please do send a pull request! This sounds like a legitimate bug. I haven't seen it, since I almost never use the "resume" feature 😇