33 Commits
Author SHA1 Message Date
Mikhail Golubev f392777e01 PY-44858 Create regular packages in refactorings initiated from top-level files in source/content roots
Otherwise, if someone wants to move a definition/extract a superclass from there to
a brand-new package, e.g. from main.py to pkg/mod.py, a namespace "pkg" package will
be created.

Restore the original behavior of PyExtractSuperclassTest.testMultifileNew: the origin
file was inside a regular project root without __init__.py alongside.

GitOrigin-RevId: 750414b18582740076c14bfcfd07fa38992b4428
2024-07-24 16:18:40 +00:00
Mikhail Golubev 1c026ac470 PY-44858 Make multifile scenarios comparing directory content in PyExtractSuperclassTests more uniform
Now they all just compare the resulting test project content with an explicit "after" directory
instead of checking individual files in the test code.

GitOrigin-RevId: cff00d0a6b8ea4547b719997716e95a3f7c62cc9
2024-07-24 16:18:40 +00:00
90bbc21f3f PY-44858 Move and other refactorings don't introduce __init__.py inside namespace packages
Namely, Move Module Members, Extract Superclass and Make Local Function Top-Level were
all affected by this.
Now we check if the refactoring origin is inside a namespace package to decide whether
__init__.py should be generated for target directories.

Co-authored-by: Kamalia <alishevakamalia@gmail.com>
Co-authored-by: Maksim.Levitskii <maksim.levitskii@jetbrains.com>

GitOrigin-RevId: b0b3420c5ec8d1f7d3000d8834211631690a0c42
2024-07-24 16:18:40 +00:00
andrey.matveev f4e98200ee PY-16221 Impl moving add from future imports when move
(cherry picked from commit b1cd64885d96c560976a29db9f5625a29df6d6ef)

IJ-MR-14916

GitOrigin-RevId: 5439442556b3d8ea2680d833109ac86559b765c1
2021-10-18 16:30:24 +00:00
Ilya.Kazakevich 38406a3b71 PY-21099: Store dependency information and use it for refactoring, obey target ref. dependency
* Dependency info may be lost when new member is created, so we store it on PSI level
* Support target reference dependency
* Method can't be abstract when property depends on it

GitOrigin-RevId: 24b9b64ef4ce60dd19bc4696e1d7aabf6a260067
2021-07-20 20:44:47 +00:00
andrey.matveev 0763dc23f0 PY-46099 Fix ClassCastException in FlaskSQLAlchemyTypeProvider
(cherry picked from commit f939dd3ae0b9811a7389c82408f8e973bf5ef2a3)

IJ-MR-5058

GitOrigin-RevId: 6b1b00fe2b7c31756a213d7729bd273095cfc9b6
2021-03-15 13:15:38 +00:00
Semyon Proshev 57216e2429 Extract some tests to separate test cases because they need Python 3 typeshed roots (PY-33830)
Remove `abc.py` used in tests and mock sdks

GitOrigin-RevId: 8f27bb056ccfbcd7961c48298b0076bed4cd0389
2019-08-19 19:59:56 +03:00
Semyon Proshev fff6955833 Move adding metaclass method (PY-30789) 2018-07-17 20:27:51 +03:00
Mikhail Golubev 30c586b5a1 PY-19705 Add an option for blanks between class header and its first method
On the whole, we don't touch these blank lines (as opposed to deleting
them previously) unless they exceed the limit specified in settings
(Keep maximum blank lines in declarations).
If someone wants to always put a blank line before the first method,
as in PY-1765, they can use this new option.
2017-09-04 16:41:35 +03:00
Mikhail Golubev e6ec37ccfe PY-19705 Add blanks lines around methods of a class as required by PEP 8 2017-07-28 15:23:31 +03:00
Ilya.Kazakevich 02fe00b54a PY-19136: Filter out nulls to prevent NPE 2016-07-01 01:31:43 +03:00
Ilya.Kazakevich bfa03fd230 PY-19137: Move object to parent in superclass extracting even for Py3K if class explicitly extends object 2016-07-01 00:55:37 +03:00
Mikhail Golubev fc8ea56374 PY-16747, PY-16770 generated abstract methods preserve formatting and prefix of original docstring 2015-09-02 14:35:41 +03:00
Mikhail Golubev 7e94358f1d Various class refactorings merge several "from imports" from abc module together 2015-06-22 17:33:57 +03:00
Mikhail Golubev 4237819376 PY-14765 Two "from imports" with the same source module are ordered by the first imported name
Additionally star imports always come first
2015-06-22 17:33:57 +03:00
Mikhail Golubev 31eeb5e84a Fix test data in several tests that failed after PyUtil#deleteElementSafely was introduces
* `pass` is consistently inserted on the new line now
* excess spaces left after element was deleted are removed

Use PyUtil#deleteElementSafely in pull, push and extract superclass
refactoring implementations.

It turned out that all problems with whitespaces left after we moved
function are rooted in awkward implementation of PyFunctionImpl#delete()
that delegated to plain AST manipulation and thus ignored
usual additional reformatting step. I removed it and it's allowed to
clean a lot of test files and remove the code that was added previously
exactly for this purpose in PyMoveSymbolProcessor.
2015-04-08 13:46:26 +03:00
Ilya.Kazakevich dd2e76a0ff PY-12178 Support pull up / push down for properties 2014-03-04 17:14:00 +04:00
Ilya.Kazakevich 2cc672b113 PY-12175 Extract superclass: import for existing super class is removed 2014-02-17 21:15:16 +04:00
Ilya.Kazakevich 621f555e9e PY-12171 Extract superclass: do not add objec base class with python 3 interpreters 2014-02-17 19:00:12 +04:00
Ilya.Kazakevich 7c1dd013e4 fake classes are not displayed as superclasses 2014-02-17 18:39:47 +04:00
Ilya.Kazakevich f20e01f8a7 PY-12170 Extract Superclass: breaks code when extracting fields not defined in __init__ 2014-02-17 18:26:22 +04:00
Ilya.Kazakevich 262ff802fe AbstractMethods copies docstrings 2014-02-17 17:38:40 +04:00
Ilya.Kazakevich b32156d3c5 PY-2858 Pull Up Abstract Method (finally!) 2014-02-14 22:03:37 +04:00
Ilya.Kazakevich 4fb93167e2 PY-10963 Pushing methods down should add needed imports fixed 2014-02-11 23:03:09 +04:00
Ilya.Kazakevich fe6b753f5b PY-10963 Pushing methods down should add needed imports (test only added) 2014-02-11 16:16:13 +04:00
Ilya.Kazakevich 24c879c5f5 Code cleanup for "membersManager" package to make it type-safe
PullUp: Refactored to use Processor on MembersManager

StatementList refactoring

PullUp: processor added

PyExtractSuperClass and PyPullMembersUp refactored and covered with tests.

PyExtractSuperClass and PyPullMembersUp refactored and covered with tests.
2014-02-06 18:31:49 +04:00
Dmitry Jemerov 279a136c14 change option "between top-level classes and functions" to "around ...", ensure that we put two lines between import and class (PY-7743) 2012-12-13 20:21:08 +01:00
Dmitry Jemerov c9136f1bb8 PEP 8 compliant option for blank lines between top-level classes/functions (PY-2765) 2011-01-26 20:21:39 +01:00
Dmitry Cheryasov ea51c512ef Better fixes and tests for PY-1788. 2010-09-28 17:59:29 +03:00
Dennis Ushakov 26090aed43 PY-1695 python imports reworked again 2010-09-13 22:44:38 +04:00
Dmitry Jemerov 235b48e046 better handling of existing superclass argument list in Extract Superclass (PY-1633) 2010-08-22 20:47:26 +04:00
Dennis Ushakov 08e3b24d20 fix test 2010-02-02 15:01:00 +03:00
Dennis Ushakov 2f9e89cc7b tests for extract superclass
formatting for extract superclass
2010-01-25 18:49:59 +03:00