Datasets:
Tasks:
Text Generation
Modalities:
Text
Formats:
json
Size:
100K - 1M
ArXiv:
Tags:
software-engineering
Dataset Viewer
fname
stringlengths 63
176
| rel_fname
stringclasses 706
values | line
int64 -1
4.5k
| name
stringlengths 1
81
| kind
stringclasses 2
values | category
stringclasses 2
values | info
stringlengths 0
77.9k
⌀ |
---|---|---|---|---|---|---|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/doc/conf.py
|
doc/conf.py
| 26 |
abspath
|
ref
|
function
|
sys.path.append(os.path.abspath("exts"))
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/doc/exts/pylint_extensions.py
|
doc/exts/pylint_extensions.py
| 17 |
builder_inited
|
def
|
function
|
def builder_inited(app):
"""Output full documentation in ReST format for all extension modules."""
# PACKAGE/docs/exts/pylint_extensions.py --> PACKAGE/
base_path = os.path.dirname(
os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
)
# PACKAGE/ --> PACKAGE/pylint/extensions
ext_path = os.path.join(base_path, "pylint", "extensions")
modules = []
doc_files = {}
for filename in os.listdir(ext_path):
name, ext = os.path.splitext(filename)
if name[0] == "_":
continue
if ext == ".py":
modules.append(f"pylint.extensions.{name}")
elif ext == ".rst":
doc_files["pylint.extensions." + name] = os.path.join(ext_path, filename)
modules.sort()
if not modules:
sys.exit("No Pylint extensions found?")
linter = PyLinter()
linter.load_plugin_modules(modules)
extensions_doc = os.path.join(
base_path, "doc", "technical_reference", "extensions.rst"
)
with open(extensions_doc, "w") as stream:
stream.write(
get_rst_title("Optional Pylint checkers in the extensions module", "=")
)
stream.write("Pylint provides the following optional plugins:\n\n")
for module in modules:
stream.write(f"- :ref:`{module}`\n")
stream.write("\n")
stream.write(
"You can activate any or all of these extensions "
"by adding a ``load-plugins`` line to the ``MASTER`` "
"section of your ``.pylintrc``, for example::\n"
)
stream.write(
"\n load-plugins=pylint.extensions.docparams,"
"pylint.extensions.docstyle\n\n"
)
# Print checker documentation to stream
by_checker = get_plugins_info(linter, doc_files)
for checker, information in sorted(by_checker.items()):
checker = information["checker"]
del information["checker"]
print(checker.get_full_documentation(**information)[:-1], file=stream)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/doc/exts/pylint_extensions.py
|
doc/exts/pylint_extensions.py
| 20 |
dirname
|
ref
|
function
|
base_path = os.path.dirname(
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/doc/exts/pylint_extensions.py
|
doc/exts/pylint_extensions.py
| 21 |
dirname
|
ref
|
function
|
os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/doc/exts/pylint_extensions.py
|
doc/exts/pylint_extensions.py
| 21 |
dirname
|
ref
|
function
|
os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/doc/exts/pylint_extensions.py
|
doc/exts/pylint_extensions.py
| 21 |
abspath
|
ref
|
function
|
os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/doc/exts/pylint_extensions.py
|
doc/exts/pylint_extensions.py
| 28 |
splitext
|
ref
|
function
|
name, ext = os.path.splitext(filename)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/doc/exts/pylint_extensions.py
|
doc/exts/pylint_extensions.py
| 39 |
PyLinter
|
ref
|
function
|
linter = PyLinter()
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/doc/exts/pylint_extensions.py
|
doc/exts/pylint_extensions.py
| 40 |
load_plugin_modules
|
ref
|
function
|
linter.load_plugin_modules(modules)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/doc/exts/pylint_extensions.py
|
doc/exts/pylint_extensions.py
| 47 |
get_rst_title
|
ref
|
function
|
get_rst_title("Optional Pylint checkers in the extensions module", "=")
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/doc/exts/pylint_extensions.py
|
doc/exts/pylint_extensions.py
| 64 |
get_plugins_info
|
ref
|
function
|
by_checker = get_plugins_info(linter, doc_files)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/doc/exts/pylint_extensions.py
|
doc/exts/pylint_extensions.py
| 68 |
get_full_documentation
|
ref
|
function
|
print(checker.get_full_documentation(**information)[:-1], file=stream)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/doc/exts/pylint_extensions.py
|
doc/exts/pylint_extensions.py
| 71 |
get_plugins_info
|
def
|
function
|
def get_plugins_info(linter, doc_files):
by_checker = {}
for checker in linter.get_checkers():
if checker.name == MAIN_CHECKER_NAME:
continue
module = checker.__module__
# Plugins only - skip over core checkers
if re.match("pylint.checkers", module):
continue
# Find any .rst documentation associated with this plugin
doc = ""
doc_file = doc_files.get(module)
if doc_file:
with open(doc_file) as f:
doc = f.read()
try:
by_checker[checker]["checker"] = checker
by_checker[checker]["options"] += checker.options_and_values()
by_checker[checker]["msgs"].update(checker.msgs)
by_checker[checker]["reports"] += checker.reports
by_checker[checker]["doc"] += doc
by_checker[checker]["module"] += module
except KeyError:
by_checker[checker] = {
"checker": checker,
"options": list(checker.options_and_values()),
"msgs": dict(checker.msgs),
"reports": list(checker.reports),
"doc": doc,
"module": module,
}
return by_checker
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/doc/exts/pylint_extensions.py
|
doc/exts/pylint_extensions.py
| 73 |
get_checkers
|
ref
|
function
|
for checker in linter.get_checkers():
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/doc/exts/pylint_extensions.py
|
doc/exts/pylint_extensions.py
| 88 |
options_and_values
|
ref
|
function
|
by_checker[checker]["options"] += checker.options_and_values()
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/doc/exts/pylint_extensions.py
|
doc/exts/pylint_extensions.py
| 96 |
options_and_values
|
ref
|
function
|
"options": list(checker.options_and_values()),
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/doc/exts/pylint_extensions.py
|
doc/exts/pylint_extensions.py
| 105 |
setup
|
def
|
function
|
def setup(app):
app.connect("builder-inited", builder_inited)
return {"version": sphinx.__display_version__}
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/doc/exts/pylint_extensions.py
|
doc/exts/pylint_extensions.py
| 106 |
connect
|
ref
|
function
|
app.connect("builder-inited", builder_inited)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/doc/exts/pylint_extensions.py
|
doc/exts/pylint_extensions.py
| 111 |
builder_inited
|
ref
|
function
|
builder_inited(None)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/doc/exts/pylint_features.py
|
doc/exts/pylint_features.py
| 14 |
builder_inited
|
def
|
function
|
def builder_inited(app):
# PACKAGE/docs/exts/pylint_extensions.py --> PACKAGE/
base_path = os.path.dirname(
os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
)
linter = PyLinter()
linter.load_default_plugins()
features = os.path.join(base_path, "doc", "technical_reference", "features.rst")
with open(features, "w") as stream:
stream.write("Pylint features\n")
stream.write("===============\n\n")
stream.write(".. generated by pylint --full-documentation\n\n")
print_full_documentation(linter, stream)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/doc/exts/pylint_features.py
|
doc/exts/pylint_features.py
| 16 |
dirname
|
ref
|
function
|
base_path = os.path.dirname(
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/doc/exts/pylint_features.py
|
doc/exts/pylint_features.py
| 17 |
dirname
|
ref
|
function
|
os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/doc/exts/pylint_features.py
|
doc/exts/pylint_features.py
| 17 |
dirname
|
ref
|
function
|
os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/doc/exts/pylint_features.py
|
doc/exts/pylint_features.py
| 17 |
abspath
|
ref
|
function
|
os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/doc/exts/pylint_features.py
|
doc/exts/pylint_features.py
| 19 |
PyLinter
|
ref
|
function
|
linter = PyLinter()
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/doc/exts/pylint_features.py
|
doc/exts/pylint_features.py
| 20 |
load_default_plugins
|
ref
|
function
|
linter.load_default_plugins()
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/doc/exts/pylint_features.py
|
doc/exts/pylint_features.py
| 26 |
print_full_documentation
|
ref
|
function
|
print_full_documentation(linter, stream)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/doc/exts/pylint_features.py
|
doc/exts/pylint_features.py
| 29 |
setup
|
def
|
function
|
def setup(app):
app.connect("builder-inited", builder_inited)
return {"version": sphinx.__display_version__}
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/doc/exts/pylint_features.py
|
doc/exts/pylint_features.py
| 30 |
connect
|
ref
|
function
|
app.connect("builder-inited", builder_inited)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/doc/exts/pylint_features.py
|
doc/exts/pylint_features.py
| 35 |
builder_inited
|
ref
|
function
|
builder_inited(None)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/doc/exts/pylint_messages.py
|
doc/exts/pylint_messages.py
| 29 |
MessageData
|
def
|
class
| |
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/doc/exts/pylint_messages.py
|
doc/exts/pylint_messages.py
| 43 |
_register_all_checkers_and_extensions
|
def
|
function
|
def _register_all_checkers_and_extensions(linter: PyLinter) -> None:
"""Registers all checkers and extensions found in the default folders."""
initialize_checkers(linter)
initialize_extensions(linter)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/doc/exts/pylint_messages.py
|
doc/exts/pylint_messages.py
| 45 |
initialize_checkers
|
ref
|
function
|
initialize_checkers(linter)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/doc/exts/pylint_messages.py
|
doc/exts/pylint_messages.py
| 46 |
initialize_extensions
|
ref
|
function
|
initialize_extensions(linter)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/doc/exts/pylint_messages.py
|
doc/exts/pylint_messages.py
| 49 |
_get_all_messages
|
def
|
function
|
def _get_all_messages(
linter: PyLinter,
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/doc/exts/pylint_messages.py
|
doc/exts/pylint_messages.py
| 73 |
MessageData
|
ref
|
function
|
message_data = MessageData(
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/doc/exts/pylint_messages.py
|
doc/exts/pylint_messages.py
| 88 |
_write_message_page
|
def
|
function
|
def _write_message_page(messages_dict: MessagesDict) -> None:
"""Create or overwrite the file for each message."""
for category, messages in messages_dict.items():
category_dir = PYLINT_MESSAGES_PATH / category
if not category_dir.exists():
category_dir.mkdir(parents=_True, exist_ok=_True)
for message in messages:
messages_file = os.path.join(category_dir, f"{message.name}.rst")
with open(messages_file, "w", encoding="utf-8") as stream:
stream.write(
f""".. _{message.name}:
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/doc/exts/pylint_messages.py
|
doc/exts/pylint_messages.py
| 100 |
get_rst_title
|
ref
|
function
|
{get_rst_title(f"{message.name} / {message.id}", "=")}
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/doc/exts/pylint_messages.py
|
doc/exts/pylint_messages.py
| 114 |
_write_messages_list_page
|
def
|
function
|
def _write_messages_list_page(
messages_dict: MessagesDict, old_messages_dict: OldMessagesDict
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/doc/exts/pylint_messages.py
|
doc/exts/pylint_messages.py
| 124 |
get_rst_title
|
ref
|
function
|
{get_rst_title("Overview of all Pylint messages", "=")}
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/doc/exts/pylint_messages.py
|
doc/exts/pylint_messages.py
| 154 |
get_rst_title
|
ref
|
function
|
f"""{get_rst_title(category.capitalize(), "-")}
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/doc/exts/pylint_messages.py
|
doc/exts/pylint_messages.py
| 174 |
_write_redirect_pages
|
def
|
function
|
def _write_redirect_pages(old_messages: OldMessagesDict) -> None:
"""Create redirect pages for old-messages."""
for category, old_names in old_messages.items():
category_dir = PYLINT_MESSAGES_PATH / category
if not os.path.exists(category_dir):
os.makedirs(category_dir)
for old_name, new_names in old_names.items():
old_name_file = os.path.join(category_dir, f"{old_name[0]}.rst")
with open(old_name_file, "w", encoding="utf-8") as stream:
new_names_string = "".join(
f" ../{new_name[1]}/{new_name[0]}.rst\n" for new_name in new_names
)
stream.write(
f""".. _{old_name[0]}:
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/doc/exts/pylint_messages.py
|
doc/exts/pylint_messages.py
| 189 |
get_rst_title
|
ref
|
function
|
{get_rst_title(" / ".join(old_name), "=")}
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/doc/exts/pylint_messages.py
|
doc/exts/pylint_messages.py
| 202 |
build_messages_pages
|
def
|
function
|
def build_messages_pages(app: Optional[Sphinx]) -> None:
"""Overwrite messages files by printing the documentation to a stream.
Documentation is written in ReST format.
"""
# Create linter, register all checkers and extensions and get all messages
linter = PyLinter()
_register_all_checkers_and_extensions(linter)
messages, old_messages = _get_all_messages(linter)
# Write message and category pages
_write_message_page(messages)
_write_messages_list_page(messages, old_messages)
# Write redirect pages
_write_redirect_pages(old_messages)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/doc/exts/pylint_messages.py
|
doc/exts/pylint_messages.py
| 207 |
PyLinter
|
ref
|
function
|
linter = PyLinter()
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/doc/exts/pylint_messages.py
|
doc/exts/pylint_messages.py
| 208 |
_register_all_checkers_and_extensions
|
ref
|
function
|
_register_all_checkers_and_extensions(linter)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/doc/exts/pylint_messages.py
|
doc/exts/pylint_messages.py
| 209 |
_get_all_messages
|
ref
|
function
|
messages, old_messages = _get_all_messages(linter)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/doc/exts/pylint_messages.py
|
doc/exts/pylint_messages.py
| 212 |
_write_message_page
|
ref
|
function
|
_write_message_page(messages)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/doc/exts/pylint_messages.py
|
doc/exts/pylint_messages.py
| 213 |
_write_messages_list_page
|
ref
|
function
|
_write_messages_list_page(messages, old_messages)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/doc/exts/pylint_messages.py
|
doc/exts/pylint_messages.py
| 216 |
_write_redirect_pages
|
ref
|
function
|
_write_redirect_pages(old_messages)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/doc/exts/pylint_messages.py
|
doc/exts/pylint_messages.py
| 219 |
setup
|
def
|
function
|
def setup(app: Sphinx) -> None:
"""Connects the extension to the Sphinx process."""
# Register callback at the builder-inited Sphinx event
# See https://www.sphinx-doc.org/en/master/extdev/appapi.html
app.connect("builder-inited", build_messages_pages)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/doc/exts/pylint_messages.py
|
doc/exts/pylint_messages.py
| 223 |
connect
|
ref
|
function
|
app.connect("builder-inited", build_messages_pages)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/examples/custom.py
|
examples/custom.py
| 13 |
MyAstroidChecker
|
def
|
class
|
visit_call
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/examples/custom.py
|
examples/custom.py
| 51 |
visit_call
|
def
|
function
|
def visit_call(self, node: nodes.Call) -> None:
"""Called when a :class:`.nodes.Call` node is visited.
See :mod:`astroid` for the description of available nodes.
"""
if not (
isinstance(node.func, nodes.Attribute)
and isinstance(node.func.expr, nodes.Name)
and node.func.expr.name == self.config.store_locals_indicator
and node.func.attrname == "create"
):
return
in_class = node.frame(future=_True)
for param in node.args:
in_class.locals[param.name] = node
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/examples/custom.py
|
examples/custom.py
| 63 |
frame
|
ref
|
class
| |
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/examples/custom.py
|
examples/custom.py
| 68 |
register
|
def
|
function
|
def register(linter: "PyLinter") -> None:
"""This required method auto registers the checker during initialization.
:param linter: The linter to register the checker to.
"""
linter.register_checker(MyAstroidChecker(linter))
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/examples/custom.py
|
examples/custom.py
| 73 |
register_checker
|
ref
|
function
|
linter.register_checker(MyAstroidChecker(linter))
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/examples/custom.py
|
examples/custom.py
| 73 |
MyAstroidChecker
|
ref
|
function
|
linter.register_checker(MyAstroidChecker(linter))
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/examples/custom_raw.py
|
examples/custom_raw.py
| 11 |
MyRawChecker
|
def
|
class
|
process_module
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/examples/custom_raw.py
|
examples/custom_raw.py
| 31 |
process_module
|
def
|
function
|
def process_module(self, node: nodes.Module) -> None:
"""Process a module.
the module's content is accessible via node.stream() function
"""
with node.stream() as stream:
for (lineno, line) in enumerate(stream):
if line.rstrip().endswith("\\"):
self.add_message("backslash-line-continuation", line=lineno)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/examples/custom_raw.py
|
examples/custom_raw.py
| 36 |
stream
|
ref
|
function
|
with node.stream() as stream:
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/examples/custom_raw.py
|
examples/custom_raw.py
| 39 |
add_message
|
ref
|
function
|
self.add_message("backslash-line-continuation", line=lineno)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/examples/custom_raw.py
|
examples/custom_raw.py
| 42 |
register
|
def
|
function
|
def register(linter: "PyLinter") -> None:
"""This required method auto registers the checker during initialization.
:param linter: The linter to register the checker to.
"""
linter.register_checker(MyRawChecker(linter))
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/examples/custom_raw.py
|
examples/custom_raw.py
| 47 |
register_checker
|
ref
|
function
|
linter.register_checker(MyRawChecker(linter))
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/examples/custom_raw.py
|
examples/custom_raw.py
| 47 |
MyRawChecker
|
ref
|
function
|
linter.register_checker(MyRawChecker(linter))
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/examples/deprecation_checker.py
|
examples/deprecation_checker.py
| 48 |
DeprecationChecker
|
def
|
class
|
deprecated_methods deprecated_arguments
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/examples/deprecation_checker.py
|
examples/deprecation_checker.py
| 60 |
deprecated_methods
|
def
|
function
|
def deprecated_methods(self) -> Set[str]:
"""Callback method called by DeprecatedMixin for every method/function found in the code.
Returns:
collections.abc.Container of deprecated function/method names.
"""
return {"mymodule.deprecated_function", "mymodule.MyClass.deprecated_method"}
def deprecated_arguments(
self, method: str
) -> Tuple[Tuple[Union[int, None], str], ...]:
"""Callback returning the deprecated arguments of method/function.
Returns:
collections.abc.Iterable in form:
((POSITION1, PARAM1), (POSITION2: PARAM2) ...)
where
* POSITIONX - position of deprecated argument PARAMX in function definition.
If argument is keyword-only, POSITIONX should be None.
* PARAMX - name of the deprecated argument.
"""
if method == "mymodule.myfunction":
# myfunction() has two deprecated arguments:
# * deprecated_arg1 defined at 2nd position and
# * deprecated_arg2 defined at 5th position.
return ((2, "deprecated_arg1"), (5, "deprecated_arg2"))
if method == "mymodule.MyClass.mymethod":
# mymethod() has two deprecated arguments:
# * deprecated1 defined at 2nd position and
# * deprecated2 defined at 4th position.
return ((2, "deprecated1"), (4, "deprecated2"))
return ()
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/examples/deprecation_checker.py
|
examples/deprecation_checker.py
| 68 |
deprecated_arguments
|
def
|
function
|
def deprecated_arguments(
self, method: str
) -> Tuple[Tuple[Union[int, None], str], ...]:
"""Callback returning the deprecated arguments of method/function.
Returns:
collections.abc.Iterable in form:
((POSITION1, PARAM1), (POSITION2: PARAM2) ...)
where
* POSITIONX - position of deprecated argument PARAMX in function definition.
If argument is keyword-only, POSITIONX should be None.
* PARAMX - name of the deprecated argument.
"""
if method == "mymodule.myfunction":
# myfunction() has two deprecated arguments:
# * deprecated_arg1 defined at 2nd position and
# * deprecated_arg2 defined at 5th position.
return ((2, "deprecated_arg1"), (5, "deprecated_arg2"))
if method == "mymodule.MyClass.mymethod":
# mymethod() has two deprecated arguments:
# * deprecated1 defined at 2nd position and
# * deprecated2 defined at 4th position.
return ((2, "deprecated1"), (4, "deprecated2"))
return ()
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/examples/deprecation_checker.py
|
examples/deprecation_checker.py
| 94 |
register
|
def
|
function
|
def register(linter: "PyLinter") -> None:
linter.register_checker(DeprecationChecker(linter))
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/examples/deprecation_checker.py
|
examples/deprecation_checker.py
| 95 |
register_checker
|
ref
|
function
|
linter.register_checker(DeprecationChecker(linter))
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/examples/deprecation_checker.py
|
examples/deprecation_checker.py
| 95 |
DeprecationChecker
|
ref
|
function
|
linter.register_checker(DeprecationChecker(linter))
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/__init__.py
|
pylint/__init__.py
| 20 |
run_pylint
|
def
|
function
|
def run_pylint(argv: Optional[Sequence[str]] = None):
"""Run pylint.
argv can be a sequence of strings normally supplied as arguments on the command line
"""
from pylint.lint import Run as PylintRun
try:
PylintRun(argv or sys.argv[1:])
except KeyboardInterrupt:
sys.exit(1)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/__init__.py
|
pylint/__init__.py
| 28 |
PylintRun
|
ref
|
function
|
PylintRun(argv or sys.argv[1:])
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/__init__.py
|
pylint/__init__.py
| 33 |
run_epylint
|
def
|
function
|
def run_epylint(argv: Optional[Sequence[str]] = None):
"""Run epylint.
argv can be a list of strings normally supplied as arguments on the command line
"""
from pylint.epylint import Run as EpylintRun
EpylintRun(argv)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/__init__.py
|
pylint/__init__.py
| 40 |
EpylintRun
|
ref
|
function
|
EpylintRun(argv)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/__init__.py
|
pylint/__init__.py
| 43 |
run_pyreverse
|
def
|
function
|
def run_pyreverse(argv: Optional[Sequence[str]] = None):
"""Run pyreverse.
argv can be a sequence of strings normally supplied as arguments on the command line
"""
from pylint.pyreverse.main import Run as PyreverseRun
PyreverseRun(argv or sys.argv[1:])
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/__init__.py
|
pylint/__init__.py
| 50 |
PyreverseRun
|
ref
|
function
|
PyreverseRun(argv or sys.argv[1:])
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/__init__.py
|
pylint/__init__.py
| 53 |
run_symilar
|
def
|
function
|
def run_symilar(argv: Optional[Sequence[str]] = None):
"""Run symilar.
argv can be a sequence of strings normally supplied as arguments on the command line
"""
from pylint.checkers.similar import Run as SimilarRun
SimilarRun(argv or sys.argv[1:])
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/__init__.py
|
pylint/__init__.py
| 60 |
SimilarRun
|
ref
|
function
|
SimilarRun(argv or sys.argv[1:])
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/__init__.py
|
pylint/__init__.py
| 63 |
modify_sys_path
|
def
|
function
|
def modify_sys_path() -> None:
"""Modify sys path for execution as Python module.
Strip out the current working directory from sys.path.
Having the working directory in `sys.path` means that `pylint` might
inadvertently import user code from modules having the same name as
stdlib or pylint's own modules.
CPython issue: https://bugs.python.org/issue33053
- Remove the first entry. This will always be either "" or the working directory
- Remove the working directory from the second and third entries
if PYTHONPATH includes a ":" at the beginning or the end.
https://github.com/PyCQA/pylint/issues/3636
Don't remove it if PYTHONPATH contains the cwd or '.' as the entry will
only be added once.
- Don't remove the working directory from the rest. It will be included
if pylint is installed in an editable configuration (as the last item).
https://github.com/PyCQA/pylint/issues/4161
"""
sys.path.pop(0)
env_pythonpath = os.environ.get("PYTHONPATH", "")
cwd = os.getcwd()
if env_pythonpath.startswith(":") and env_pythonpath not in (f":{cwd}", ":."):
sys.path.pop(0)
elif env_pythonpath.endswith(":") and env_pythonpath not in (f"{cwd}:", ".:"):
sys.path.pop(1)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/__main__.py
|
pylint/__main__.py
| 7 |
modify_sys_path
|
ref
|
function
|
pylint.modify_sys_path()
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/__main__.py
|
pylint/__main__.py
| 8 |
run_pylint
|
ref
|
function
|
pylint.run_pylint()
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/__pkginfo__.py
|
pylint/__pkginfo__.py
| 7 |
get_numversion_from_version
|
def
|
function
|
def get_numversion_from_version(v: str) -> Tuple:
"""Kept for compatibility reason.
See https://github.com/PyCQA/pylint/issues/4399
https://github.com/PyCQA/pylint/issues/4420,
"""
v = v.replace("pylint-", "")
version = []
for n in v.split(".")[0:3]:
try:
version.append(int(n))
except ValueError:
num = ""
for c in n:
if c.isdigit():
num += c
else:
break
try:
version.append(int(num))
except ValueError:
version.append(0)
while len(version) != 3:
version.append(0)
return tuple(version)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/__pkginfo__.py
|
pylint/__pkginfo__.py
| 34 |
get_numversion_from_version
|
ref
|
function
|
numversion = get_numversion_from_version(__version__)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/__init__.py
|
pylint/checkers/__init__.py
| 73 |
table_lines_from_stats
|
def
|
function
|
def table_lines_from_stats(
stats: LinterStats,
old_stats: Optional[LinterStats],
stat_type: Literal["duplicated_lines", "message_types"],
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/__init__.py
|
pylint/checkers/__init__.py
| 130 |
diff_string
|
ref
|
function
|
diff_string(old_value, new_value)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/__init__.py
|
pylint/checkers/__init__.py
| 140 |
initialize
|
def
|
function
|
def initialize(linter):
"""Initialize linter with checkers in this package."""
register_plugins(linter, __path__[0])
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/__init__.py
|
pylint/checkers/__init__.py
| 142 |
register_plugins
|
ref
|
function
|
register_plugins(linter, __path__[0])
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/async.py
|
pylint/checkers/async.py
| 26 |
AsyncChecker
|
def
|
class
|
open visit_asyncfunctiondef visit_asyncwith
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/async.py
|
pylint/checkers/async.py
| 47 |
get_global_option
|
ref
|
function
|
self._ignore_mixin_members = utils.get_global_option(
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/async.py
|
pylint/checkers/async.py
| 50 |
get_global_option
|
ref
|
class
| |
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/async.py
|
pylint/checkers/async.py
| 53 |
check_messages
|
ref
|
function
|
@checker_utils.check_messages("yield-inside-async-function")
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/async.py
|
pylint/checkers/async.py
| 54 |
visit_asyncfunctiondef
|
def
|
function
|
def visit_asyncfunctiondef(self, node: nodes.AsyncFunctionDef) -> None:
for child in node.nodes_of_class(nodes.Yield):
if child.scope() is node and (
sys.version_info[:2] == (3, 5) or isinstance(child, nodes.YieldFrom)
):
self.add_message("yield-inside-async-function", node=child)
@checker_utils.check_messages("not-async-context-manager")
def visit_asyncwith(self, node: nodes.AsyncWith) -> None:
for ctx_mgr, _ in node.items:
inferred = checker_utils.safe_infer(ctx_mgr)
if inferred is None or inferred is astroid.Uninferable:
continue
if isinstance(inferred, nodes.AsyncFunctionDef):
# Check if we are dealing with a function decorated
# with contextlib.asynccontextmanager.
if decorated_with(inferred, self._async_generators):
continue
elif isinstance(inferred, astroid.bases.AsyncGenerator):
# Check if we are dealing with a function decorated
# with contextlib.asynccontextmanager.
if decorated_with(inferred.parent, self._async_generators):
continue
else:
try:
inferred.getattr("__aenter__")
inferred.getattr("__aexit__")
except astroid.exceptions.NotFoundError:
if isinstance(inferred, astroid.Instance):
# If we do not know the bases of this class,
# just skip it.
if not checker_utils.has_known_bases(inferred):
continue
# Ignore mixin classes if they match the rgx option.
if self._ignore_mixin_members and self._mixin_class_rgx.match(
inferred.name
):
continue
else:
continue
self.add_message(
"not-async-context-manager", node=node, args=(inferred.name,)
)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/async.py
|
pylint/checkers/async.py
| 55 |
nodes_of_class
|
ref
|
class
| |
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/async.py
|
pylint/checkers/async.py
| 56 |
scope
|
ref
|
function
|
if child.scope() is node and (
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/async.py
|
pylint/checkers/async.py
| 59 |
add_message
|
ref
|
function
|
self.add_message("yield-inside-async-function", node=child)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/async.py
|
pylint/checkers/async.py
| 61 |
check_messages
|
ref
|
function
|
@checker_utils.check_messages("not-async-context-manager")
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/async.py
|
pylint/checkers/async.py
| 62 |
visit_asyncwith
|
def
|
function
|
def visit_asyncwith(self, node: nodes.AsyncWith) -> None:
for ctx_mgr, _ in node.items:
inferred = checker_utils.safe_infer(ctx_mgr)
if inferred is None or inferred is astroid.Uninferable:
continue
if isinstance(inferred, nodes.AsyncFunctionDef):
# Check if we are dealing with a function decorated
# with contextlib.asynccontextmanager.
if decorated_with(inferred, self._async_generators):
continue
elif isinstance(inferred, astroid.bases.AsyncGenerator):
# Check if we are dealing with a function decorated
# with contextlib.asynccontextmanager.
if decorated_with(inferred.parent, self._async_generators):
continue
else:
try:
inferred.getattr("__aenter__")
inferred.getattr("__aexit__")
except astroid.exceptions.NotFoundError:
if isinstance(inferred, astroid.Instance):
# If we do not know the bases of this class,
# just skip it.
if not checker_utils.has_known_bases(inferred):
continue
# Ignore mixin classes if they match the rgx option.
if self._ignore_mixin_members and self._mixin_class_rgx.match(
inferred.name
):
continue
else:
continue
self.add_message(
"not-async-context-manager", node=node, args=(inferred.name,)
)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/async.py
|
pylint/checkers/async.py
| 64 |
safe_infer
|
ref
|
function
|
inferred = checker_utils.safe_infer(ctx_mgr)
|
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/checkers/async.py
|
pylint/checkers/async.py
| 71 |
decorated_with
|
ref
|
function
|
if decorated_with(inferred, self._async_generators):
|
End of preview. Expand
in Data Studio
This repo contains cached trajectories of the paper RepoGraph: Enhancing AI Software Engineering with Repository-level Code Graph.
- Downloads last month
- 187