Skip to content

0.5.0

Compare
Choose a tag to compare
@isidentical isidentical released this 07 Aug 12:27

0.5.0

Note: With this release, we also started improving our documentation. If you are interested in Refactor, check the new layout and tutorials out and let us know how you feel!

Major

This release includes the overhaul of our action system, and with the next releases we will start removing the old ones. A list
of changes regarding actions can be seen here:

  • refactor.core no longer contains any actions (the deprecated aliases are still imported and exposed but all the new actions go into refactor.actions)
  • Action is now split into two, a refactor.actions.BaseAction which is the base of all actions (useful for type hinting) and a refactor.actions.LazyReplace (a replace action that builds the node lazily in its build()).
  • ReplacementAction is now refactor.actions.Replace
  • NewStatementAction is now refactor.actions.LazyInsertAfter
  • TargetedNewStatementAction is now refactor.actions.InsertAfter

For migrating your code base to the new style actions, we wrote a small tool (that we also used internally), examples/deprecated_aliases.py. Feel free to try it, and let us know if the transition was seamless.

Other Changes

  • Added experimental Windows support, contributed by Hakan Celik
  • common.find_closest now takes end_lineno and end_col_offset into account. It also ensures there is at least one target node.
  • Added debug_mode setting to refactor.context.Configuration.
  • Added a command-line flag (-d/--enable-debug-mode) to the default CLI runner to change session's configuration.
  • When unparsable source code is generated, the contents can be now seen if the debug mode is enabled.
  • [Experimental] Added ability to partially recover floating comments (from preceding or succeeding lines) bound to statements.
  • The context providers now can be accessed with attribute notation, e.g. self.context.scope instead of self.context.metadata["scope].
  • If you access a built-in context provider (scope/ancestry) and it is not already imported, we auto-import it. So most common context providers are now ready to be used.
  • Added common.next_statement_of.