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

initial docstring support #515

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 10 additions & 22 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# **Upcoming release**

- #516 Autoimport Now automatically detects project dependencies and can read TOML configuration
- #515 Autoimport now gathers docstrings of imported names and modules (@bagel897).
- #733 skip directories with perm error when building autoimport index (@MrBago)
- #722, #723 Remove site-packages from packages search tree (@tkrabel)
- #738 Implement os.PathLike on Resource (@lieryan)
Expand All @@ -25,10 +27,10 @@
# Release 1.8.0

- #650 Install pre-commit hooks on rope repository (@lieryan)
- #655 Remove unused __init__() methods (@edreamleo, @lieryan)
- #655 Remove unused **init**() methods (@edreamleo, @lieryan)
- #656 Reformat using black 23.1.0 (@edreamleo)
- #674 Fix/supress all mypy complaints (@edreamleo)
- #680 Remove a do-nothing statement in soi._handle_first_parameter (@edreamleo)
- #680 Remove a do-nothing statement in soi.\_handle_first_parameter (@edreamleo)
- #687, #688 Fix autoimport not scanning packages recursively (@lieryan)

# Release 1.7.0
Expand All @@ -42,15 +44,17 @@
- #627 Fix parsing of octal literal (@lieryan)
- #643, #435 Fix fstrings with mismatched parens (@apmorton)
- #646 Fix renaming kwargs when refactoring from imports (@apmorton)
- #648 Remove __init__ from import statement when using sqlite autoimport (@bagel897)
- #648 Remove **init** from import statement when using sqlite autoimport (@bagel897)

## Improvements

- rope.contrib.generate improvements

- #640 Remove unnecessary eval in generate.py (@edreamleo)
- #641 Add type annotations for rope.contrib.generate.create_generate() (@edreamleo)

- call_for_nodes() improvements

- #634 Remove call_for_nodes(recursive) argument (@edreamleo)
- #642 Add comments & docstrings related to call_for_nodes (@edreamleo, @lieryan)

Expand All @@ -73,7 +77,6 @@
- #620 Remove unused import in occurrences.py (@edreamleo)
- #625 Remove support for deprecated ast nodes (@lieryan)


## Tests/Dev

- #626 Install pre-commit hooks on rope repository (@lieryan)
Expand All @@ -84,7 +87,6 @@

- #636 Update readme to reflect 1.0 has been released. (@maxnoe)


# Release 1.6.0

## New features & Enhancements
Expand Down Expand Up @@ -117,7 +119,6 @@
- pynames and pyobjects
- #569, #572 rename pynames to pynamesdef in pyobjectsdef.ph (@edreamleo)


# Release 1.5.1

- #531 Add alternative way to retrieve version number from pyproject.toml
Expand All @@ -132,7 +133,6 @@ Date: 2022-11-23
- #522 Implement patchedast parsing of MatchMapping (@lieryan)
- #514 Fix inlining dictionary with inline comment (@lieryan)


# Release 1.4.0

Date: 2022-10-22
Expand All @@ -143,7 +143,6 @@ Date: 2022-10-22
- #411, #505 Fix extracting generator without parens
- #18, #510 When the function is a builtin function, the call parameter's name was sometimes incorrectly identified as an AssignedName. This led to rename refactoring incorrectly renaming these parameters.


# Release 1.3.0

Date: 2022-07-29
Expand All @@ -157,7 +156,6 @@ Date: 2022-07-29

- #501, #502 Autoimport improvements


# Release 1.2.0

Date: 2022-04-22
Expand All @@ -172,17 +170,15 @@ Date: 2022-04-22

- #479 Add ABC and type hints for TaskHandle and JobSet (@bageljrkhanofemus)
- #486 Drop Python 2 support (@bageljrkhanofemus, @lieryan)
- #487 Improved value inference of __all__ declaration (@lieryan)
- #424 Add some basic __repr__ to make it easier for debugging (@lieryan)

- #487 Improved value inference of **all** declaration (@lieryan)
- #424 Add some basic **repr** to make it easier for debugging (@lieryan)

# Release 1.1.1

## Bug fixes

- #476 Fix rope.contrib.autoimport package missing from release (@bageljrkhanofemus)


# Release 1.1.0

Date: 2022-05-25
Expand All @@ -202,7 +198,6 @@ Date: 2022-05-25

- The pickle-based autoimport implementation is still the default, but will be deprecated sometime in the future.


# Release 1.0.0

Date: 2022-04-08
Expand All @@ -215,7 +210,6 @@ Date: 2022-04-08

- #459 Fix bug while extracting method with augmented assignment to subscript in try block (@dryobates)


# Release 0.23.0

## Syntax support
Expand All @@ -226,15 +220,14 @@ Date: 2022-04-08

## Bug fixes

- #134, #453 Preserve newline format when writing files (@lieryan)
- #134, #453 Preserve newline format when writing files (@lieryan)
- #457 Fix extract info collection for list comprehension with multiple targets
(@lieryan)

## Documentation

- #455 Fix typo (@Jasha10)


# Release 0.22.0

Date: 2021-11-23
Expand All @@ -252,7 +245,6 @@ Date: 2021-11-23

- #447 Add Python 3.10 to tests


# Release 0.21.1

Date: 2021-11-11
Expand All @@ -261,7 +253,6 @@ Date: 2021-11-11

- #441. Start publishing wheel packages to allow offline installs


# Release 0.21.0

Date: 2021-10-18
Expand Down Expand Up @@ -299,7 +290,6 @@ Date: 2021-10-18
- #399 Add Github Actions to enforce black code style (@lieryan)
- #403 Remove plain 'unittest' only runner (@lieryan)


# Release 0.20.1

Date: 2021-09-18
Expand All @@ -309,7 +299,6 @@ Date: 2021-09-18
- Fix caller of `_namedexpr_last()` throwing exception due to returning unexpected list
instead of boolean


# Release 0.20.0

Date: 2021-09-18
Expand All @@ -331,7 +320,6 @@ Date: 2021-09-18

- #380 Fix list of variables that are returned and/or turned into argument when extracting method in a loop


# Previous releases

[Changelog from pre-0.10.0](https://github.com/python-rope/rope/blob/595af418e7e7e844dcce600778e1c650c2fc0ba1/docs/done.rst).
9 changes: 8 additions & 1 deletion docs/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Will be used if [tool.rope] is configured.

[tool.rope]
split_imports = true
[tool.rope.autoimport]
underlined = false

config.py
---------
Expand Down Expand Up @@ -56,9 +58,14 @@ It follows the exact same syntax of the pyproject.toml.


Options
-------
=======
.. autopytoolconfigtable:: rope.base.prefs.Prefs

Autoimport Options
------------------
.. autopytoolconfigtable:: rope.base.prefs.AutoimportPrefs


Old Configuration File
----------------------
This is a sample config.py. While this config.py works and all options here should be supported, the above documentation reflects the latest version of rope.
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ classifiers = [
'Topic :: Software Development',
]
version = '1.11.0'
dependencies = ['pytoolconfig[global] >= 1.2.2']
dependencies = ['pytoolconfig[global] >= 1.3.0']

[[project.authors]]
name = 'Ali Gholami Rudi'
Expand Down
16 changes: 16 additions & 0 deletions rope/base/prefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# type: ignore
"""Rope preferences."""
from dataclasses import asdict, dataclass
from enum import Enum, unique
from textwrap import dedent
from typing import Any, Callable, Dict, List, Optional, Tuple

Expand All @@ -10,6 +11,19 @@
from pytoolconfig.sources import Source

from rope.base.resources import Folder
@unique
class DocumentationMode(Enum):
DISABLED = False
ENABLED = True
LAZY = "lazy"

@dataclass
class AutoimportPrefs:
underlined: bool = field(
default=False, description="Cache underlined (private) modules")
memory: bool = field(default=None, description="Cache in memory instead of disk")
parallel: bool = field(default=True, description="Use multiple processes to parse")
documentation: DocumentationMode = field(default=DocumentationMode.DISABLED, description="Cache documentation")


@dataclass
Expand Down Expand Up @@ -206,6 +220,8 @@ class Prefs:
Can only be set in config.py.
"""),
)
autoimport: AutoimportPrefs = field(
default_factory=lambda: AutoimportPrefs(), description="Preferences for Autoimport")

def set(self, key: str, value: Any):
"""Set the value of `key` preference to `value`."""
Expand Down
5 changes: 4 additions & 1 deletion rope/base/versioning.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import dataclasses
import hashlib
import importlib.util
import json
Expand Down Expand Up @@ -31,7 +32,9 @@ def _get_prefs_data(project) -> str:
del prefs_data["project_opened"]
del prefs_data["callbacks"]
del prefs_data["dependencies"]
return json.dumps(prefs_data, sort_keys=True, indent=2)
return json.dumps(
prefs_data, sort_keys=True, indent=2, default=lambda o: o.__dict__
)


def _get_file_content(module_name: str) -> str:
Expand Down
7 changes: 7 additions & 0 deletions rope/contrib/autoimport/defs.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class ModuleInfo(NamedTuple):
modname: str
underlined: bool
process_imports: bool
description: str


class ModuleFile(ModuleInfo):
Expand Down Expand Up @@ -100,19 +101,25 @@ class Name(NamedTuple):
package: str
source: Source
name_type: NameType
description: str
mod_desc: str


class PartialName(NamedTuple):
"""Partial information of a Name."""

name: str
name_type: NameType
description: str
mod_desc: str


class SearchResult(NamedTuple):
"""Search Result."""

import_statement: str
name: str
modname: str
source: int
itemkind: int
description: str
2 changes: 2 additions & 0 deletions rope/contrib/autoimport/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ class Name(Model):
"package": "TEXT",
"source": "INTEGER",
"type": "INTEGER",
"description": "TEXT",
"mod_desc": "TEXT",
}
columns = list(schema.keys())
objects = Query(table_name, columns)
Expand Down
Loading
Loading