-
Notifications
You must be signed in to change notification settings - Fork 166
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
commit c4b7ada05a63c92c94e17cd6383c90284a16b820 Author: bagel897 <[email protected]> Date: Wed Jan 10 11:16:51 2024 -0600 reformat commit eb8e5fb Author: bagel897 <[email protected]> Date: Mon Nov 7 23:17:15 2022 -0600 Clean docs, add async support commit a07151a Merge: 1f0556c 764bbe1 Author: Bagel <[email protected]> Date: Thu Nov 3 20:46:31 2022 -0500 Merge branch 'master' into autoimport_docstring commit 1f0556c Author: bagel897 <[email protected]> Date: Thu Nov 3 01:52:32 2022 -0500 Expose the modname commit 3788d54 Author: bagel897 <[email protected]> Date: Thu Nov 3 00:52:52 2022 -0500 initial docstring support
- Loading branch information
Showing
7 changed files
with
134 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,61 @@ | ||
import os | ||
import pathlib | ||
import sys | ||
import typing | ||
from inspect import getdoc | ||
from os import _exit | ||
from sys import exit | ||
|
||
from rope.contrib.autoimport import parse | ||
from rope.contrib.autoimport.defs import Name, NameType, PartialName, Source | ||
|
||
|
||
def test_typing_names(typing_path): | ||
names = list(parse.get_names_from_file(typing_path)) | ||
assert PartialName("Text", NameType.Variable) in names | ||
# No docs for typing, its docstrings are SUPER weird | ||
assert PartialName("Text", NameType.Variable, "", getdoc(typing)) in names | ||
|
||
|
||
def test_docstring(): | ||
names = list( | ||
node | ||
for node in parse.get_names_from_file(pathlib.Path(pathlib.__file__)) | ||
if node.name == "Path" | ||
) | ||
assert ( | ||
PartialName("Path", NameType.Class, getdoc(pathlib.Path), getdoc(pathlib) or "") | ||
in names | ||
) | ||
|
||
|
||
def test_find_sys(): | ||
names = list(parse.get_names_from_compiled("sys", Source.BUILTIN)) | ||
assert Name("exit", "sys", "sys", Source.BUILTIN, NameType.Function) in names | ||
print(names) | ||
assert ( | ||
Name( | ||
"exit", | ||
"sys", | ||
"sys", | ||
Source.BUILTIN, | ||
NameType.Function, | ||
getdoc(exit), | ||
getdoc(sys), | ||
) | ||
in names | ||
) | ||
|
||
|
||
def test_find_underlined(): | ||
names = list(parse.get_names_from_compiled("os", Source.BUILTIN, underlined=True)) | ||
assert Name("_exit", "os", "os", Source.BUILTIN, NameType.Function) in names | ||
assert ( | ||
Name( | ||
"_exit", | ||
"os", | ||
"os", | ||
Source.BUILTIN, | ||
NameType.Function, | ||
getdoc(_exit), | ||
getdoc(os), | ||
) | ||
in names | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters