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/pylint/lint/run.py
pylint/lint/run.py
342
set_option
ref
function
linter.set_option("jobs", 1)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/run.py
pylint/lint/run.py
344
_cpu_count
ref
function
linter.config.jobs = _cpu_count()
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/run.py
pylint/lint/run.py
350
check
ref
function
linter.check(args)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/run.py
pylint/lint/run.py
351
generate_reports
ref
function
score_value = linter.generate_reports()
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/run.py
pylint/lint/run.py
356
check
ref
function
linter.check(args)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/run.py
pylint/lint/run.py
357
generate_reports
ref
function
score_value = linter.generate_reports()
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/run.py
pylint/lint/run.py
369
any_fail_on_issues
ref
function
elif linter.any_fail_on_issues():
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/run.py
pylint/lint/run.py
383
version_asked
def
function
def version_asked(self, _, __): """Callback for version (i.e. before option parsing).""" self._version_asked = _True def cb_set_rcfile(self, name, value): """Callback for option preprocessing (i.e. before option parsing).""" self._rcfile = value def cb_set_output(self, name, value): """Callback for option preprocessing (i.e. before option parsing).""" self._output = value def cb_add_plugins(self, name, value): """Callback for option preprocessing (i.e. before option parsing).""" self._plugins.extend(utils._splitstrip(value)) def cb_error_mode(self, *args, **kwargs): """Error mode: * disable all but error messages * disable the 'miscellaneous' checker which can be safely deactivated in debug * disable reports * do not save execution information """ self.linter.error_mode() def cb_generate_config(self, *args, **kwargs): """Optik callback for sample config file generation.""" self.linter.generate_config(skipsections=("COMMANDS",)) sys.exit(0) def cb_generate_manpage(self, *args, **kwargs): """Optik callback for sample config file generation.""" self.linter.generate_manpage(__pkginfo__) sys.exit(0) def cb_help_message(self, option, optname, value, parser): """Optik callback for printing some help about a particular message.""" self.linter.msgs_store.help_message(utils._splitstrip(value)) sys.exit(0) def cb_full_documentation(self, option, optname, value, parser): """Optik callback for printing full documentation.""" print_full_documentation(self.linter) sys.exit(0) def cb_list_messages(self, option, optname, value, parser): """Optik callback for printing available messages.""" self.linter.msgs_store.list_messages() sys.exit(0) def cb_list_messages_enabled(self, option, optname, value, parser): """Optik callback for printing available messages.""" self.linter.list_messages_enabled() sys.exit(0) def cb_list_groups(self, *args, **kwargs): """List all the check groups that pylint knows about. These should be useful to know what check groups someone can disable or enable. """ for check in self.linter.get_checker_names(): print(check) sys.exit(0) def cb_verbose_mode(self, *args, **kwargs): self.verbose = _True def cb_enable_all_extensions(self, option_name: str, value: None) -> None: """Callback to load and enable all available extensions.""" for filename in os.listdir(os.path.dirname(extensions.__file__)): if filename.endswith(".py") and not filename.startswith("_"): extension_name = f"pylint.extensions.{filename[:-3]}" if extension_name not in self._plugins: self._plugins.append(extension_name)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/run.py
pylint/lint/run.py
387
cb_set_rcfile
def
function
def cb_set_rcfile(self, name, value): """Callback for option preprocessing (i.e. before option parsing).""" self._rcfile = value def cb_set_output(self, name, value): """Callback for option preprocessing (i.e. before option parsing).""" self._output = value def cb_add_plugins(self, name, value): """Callback for option preprocessing (i.e. before option parsing).""" self._plugins.extend(utils._splitstrip(value)) def cb_error_mode(self, *args, **kwargs): """Error mode: * disable all but error messages * disable the 'miscellaneous' checker which can be safely deactivated in debug * disable reports * do not save execution information """ self.linter.error_mode() def cb_generate_config(self, *args, **kwargs): """Optik callback for sample config file generation.""" self.linter.generate_config(skipsections=("COMMANDS",)) sys.exit(0) def cb_generate_manpage(self, *args, **kwargs): """Optik callback for sample config file generation.""" self.linter.generate_manpage(__pkginfo__) sys.exit(0) def cb_help_message(self, option, optname, value, parser): """Optik callback for printing some help about a particular message.""" self.linter.msgs_store.help_message(utils._splitstrip(value)) sys.exit(0) def cb_full_documentation(self, option, optname, value, parser): """Optik callback for printing full documentation.""" print_full_documentation(self.linter) sys.exit(0) def cb_list_messages(self, option, optname, value, parser): """Optik callback for printing available messages.""" self.linter.msgs_store.list_messages() sys.exit(0) def cb_list_messages_enabled(self, option, optname, value, parser): """Optik callback for printing available messages.""" self.linter.list_messages_enabled() sys.exit(0) def cb_list_groups(self, *args, **kwargs): """List all the check groups that pylint knows about. These should be useful to know what check groups someone can disable or enable. """ for check in self.linter.get_checker_names(): print(check) sys.exit(0) def cb_verbose_mode(self, *args, **kwargs): self.verbose = _True def cb_enable_all_extensions(self, option_name: str, value: None) -> None: """Callback to load and enable all available extensions.""" for filename in os.listdir(os.path.dirname(extensions.__file__)): if filename.endswith(".py") and not filename.startswith("_"): extension_name = f"pylint.extensions.{filename[:-3]}" if extension_name not in self._plugins: self._plugins.append(extension_name)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/run.py
pylint/lint/run.py
391
cb_set_output
def
function
def cb_set_output(self, name, value): """Callback for option preprocessing (i.e. before option parsing).""" self._output = value def cb_add_plugins(self, name, value): """Callback for option preprocessing (i.e. before option parsing).""" self._plugins.extend(utils._splitstrip(value)) def cb_error_mode(self, *args, **kwargs): """Error mode: * disable all but error messages * disable the 'miscellaneous' checker which can be safely deactivated in debug * disable reports * do not save execution information """ self.linter.error_mode() def cb_generate_config(self, *args, **kwargs): """Optik callback for sample config file generation.""" self.linter.generate_config(skipsections=("COMMANDS",)) sys.exit(0) def cb_generate_manpage(self, *args, **kwargs): """Optik callback for sample config file generation.""" self.linter.generate_manpage(__pkginfo__) sys.exit(0) def cb_help_message(self, option, optname, value, parser): """Optik callback for printing some help about a particular message.""" self.linter.msgs_store.help_message(utils._splitstrip(value)) sys.exit(0) def cb_full_documentation(self, option, optname, value, parser): """Optik callback for printing full documentation.""" print_full_documentation(self.linter) sys.exit(0) def cb_list_messages(self, option, optname, value, parser): """Optik callback for printing available messages.""" self.linter.msgs_store.list_messages() sys.exit(0) def cb_list_messages_enabled(self, option, optname, value, parser): """Optik callback for printing available messages.""" self.linter.list_messages_enabled() sys.exit(0) def cb_list_groups(self, *args, **kwargs): """List all the check groups that pylint knows about. These should be useful to know what check groups someone can disable or enable. """ for check in self.linter.get_checker_names(): print(check) sys.exit(0) def cb_verbose_mode(self, *args, **kwargs): self.verbose = _True def cb_enable_all_extensions(self, option_name: str, value: None) -> None: """Callback to load and enable all available extensions.""" for filename in os.listdir(os.path.dirname(extensions.__file__)): if filename.endswith(".py") and not filename.startswith("_"): extension_name = f"pylint.extensions.{filename[:-3]}" if extension_name not in self._plugins: self._plugins.append(extension_name)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/run.py
pylint/lint/run.py
395
cb_add_plugins
def
function
def cb_add_plugins(self, name, value): """Callback for option preprocessing (i.e. before option parsing).""" self._plugins.extend(utils._splitstrip(value)) def cb_error_mode(self, *args, **kwargs): """Error mode: * disable all but error messages * disable the 'miscellaneous' checker which can be safely deactivated in debug * disable reports * do not save execution information """ self.linter.error_mode() def cb_generate_config(self, *args, **kwargs): """Optik callback for sample config file generation.""" self.linter.generate_config(skipsections=("COMMANDS",)) sys.exit(0) def cb_generate_manpage(self, *args, **kwargs): """Optik callback for sample config file generation.""" self.linter.generate_manpage(__pkginfo__) sys.exit(0) def cb_help_message(self, option, optname, value, parser): """Optik callback for printing some help about a particular message.""" self.linter.msgs_store.help_message(utils._splitstrip(value)) sys.exit(0) def cb_full_documentation(self, option, optname, value, parser): """Optik callback for printing full documentation.""" print_full_documentation(self.linter) sys.exit(0) def cb_list_messages(self, option, optname, value, parser): """Optik callback for printing available messages.""" self.linter.msgs_store.list_messages() sys.exit(0) def cb_list_messages_enabled(self, option, optname, value, parser): """Optik callback for printing available messages.""" self.linter.list_messages_enabled() sys.exit(0) def cb_list_groups(self, *args, **kwargs): """List all the check groups that pylint knows about. These should be useful to know what check groups someone can disable or enable. """ for check in self.linter.get_checker_names(): print(check) sys.exit(0) def cb_verbose_mode(self, *args, **kwargs): self.verbose = _True def cb_enable_all_extensions(self, option_name: str, value: None) -> None: """Callback to load and enable all available extensions.""" for filename in os.listdir(os.path.dirname(extensions.__file__)): if filename.endswith(".py") and not filename.startswith("_"): extension_name = f"pylint.extensions.{filename[:-3]}" if extension_name not in self._plugins: self._plugins.append(extension_name)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/run.py
pylint/lint/run.py
397
_splitstrip
ref
function
self._plugins.extend(utils._splitstrip(value))
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/run.py
pylint/lint/run.py
399
cb_error_mode
def
function
def cb_error_mode(self, *args, **kwargs): """Error mode: * disable all but error messages * disable the 'miscellaneous' checker which can be safely deactivated in debug * disable reports * do not save execution information """ self.linter.error_mode() def cb_generate_config(self, *args, **kwargs): """Optik callback for sample config file generation.""" self.linter.generate_config(skipsections=("COMMANDS",)) sys.exit(0) def cb_generate_manpage(self, *args, **kwargs): """Optik callback for sample config file generation.""" self.linter.generate_manpage(__pkginfo__) sys.exit(0) def cb_help_message(self, option, optname, value, parser): """Optik callback for printing some help about a particular message.""" self.linter.msgs_store.help_message(utils._splitstrip(value)) sys.exit(0) def cb_full_documentation(self, option, optname, value, parser): """Optik callback for printing full documentation.""" print_full_documentation(self.linter) sys.exit(0) def cb_list_messages(self, option, optname, value, parser): """Optik callback for printing available messages.""" self.linter.msgs_store.list_messages() sys.exit(0) def cb_list_messages_enabled(self, option, optname, value, parser): """Optik callback for printing available messages.""" self.linter.list_messages_enabled() sys.exit(0) def cb_list_groups(self, *args, **kwargs): """List all the check groups that pylint knows about. These should be useful to know what check groups someone can disable or enable. """ for check in self.linter.get_checker_names(): print(check) sys.exit(0) def cb_verbose_mode(self, *args, **kwargs): self.verbose = _True def cb_enable_all_extensions(self, option_name: str, value: None) -> None: """Callback to load and enable all available extensions.""" for filename in os.listdir(os.path.dirname(extensions.__file__)): if filename.endswith(".py") and not filename.startswith("_"): extension_name = f"pylint.extensions.{filename[:-3]}" if extension_name not in self._plugins: self._plugins.append(extension_name)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/run.py
pylint/lint/run.py
407
error_mode
ref
function
self.linter.error_mode()
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/run.py
pylint/lint/run.py
409
cb_generate_config
def
function
def cb_generate_config(self, *args, **kwargs): """Optik callback for sample config file generation.""" self.linter.generate_config(skipsections=("COMMANDS",)) sys.exit(0) def cb_generate_manpage(self, *args, **kwargs): """Optik callback for sample config file generation.""" self.linter.generate_manpage(__pkginfo__) sys.exit(0) def cb_help_message(self, option, optname, value, parser): """Optik callback for printing some help about a particular message.""" self.linter.msgs_store.help_message(utils._splitstrip(value)) sys.exit(0) def cb_full_documentation(self, option, optname, value, parser): """Optik callback for printing full documentation.""" print_full_documentation(self.linter) sys.exit(0) def cb_list_messages(self, option, optname, value, parser): """Optik callback for printing available messages.""" self.linter.msgs_store.list_messages() sys.exit(0) def cb_list_messages_enabled(self, option, optname, value, parser): """Optik callback for printing available messages.""" self.linter.list_messages_enabled() sys.exit(0) def cb_list_groups(self, *args, **kwargs): """List all the check groups that pylint knows about. These should be useful to know what check groups someone can disable or enable. """ for check in self.linter.get_checker_names(): print(check) sys.exit(0) def cb_verbose_mode(self, *args, **kwargs): self.verbose = _True def cb_enable_all_extensions(self, option_name: str, value: None) -> None: """Callback to load and enable all available extensions.""" for filename in os.listdir(os.path.dirname(extensions.__file__)): if filename.endswith(".py") and not filename.startswith("_"): extension_name = f"pylint.extensions.{filename[:-3]}" if extension_name not in self._plugins: self._plugins.append(extension_name)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/run.py
pylint/lint/run.py
411
generate_config
ref
function
self.linter.generate_config(skipsections=("COMMANDS",))
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/run.py
pylint/lint/run.py
414
cb_generate_manpage
def
function
def cb_generate_manpage(self, *args, **kwargs): """Optik callback for sample config file generation.""" self.linter.generate_manpage(__pkginfo__) sys.exit(0) def cb_help_message(self, option, optname, value, parser): """Optik callback for printing some help about a particular message.""" self.linter.msgs_store.help_message(utils._splitstrip(value)) sys.exit(0) def cb_full_documentation(self, option, optname, value, parser): """Optik callback for printing full documentation.""" print_full_documentation(self.linter) sys.exit(0) def cb_list_messages(self, option, optname, value, parser): """Optik callback for printing available messages.""" self.linter.msgs_store.list_messages() sys.exit(0) def cb_list_messages_enabled(self, option, optname, value, parser): """Optik callback for printing available messages.""" self.linter.list_messages_enabled() sys.exit(0) def cb_list_groups(self, *args, **kwargs): """List all the check groups that pylint knows about. These should be useful to know what check groups someone can disable or enable. """ for check in self.linter.get_checker_names(): print(check) sys.exit(0) def cb_verbose_mode(self, *args, **kwargs): self.verbose = _True def cb_enable_all_extensions(self, option_name: str, value: None) -> None: """Callback to load and enable all available extensions.""" for filename in os.listdir(os.path.dirname(extensions.__file__)): if filename.endswith(".py") and not filename.startswith("_"): extension_name = f"pylint.extensions.{filename[:-3]}" if extension_name not in self._plugins: self._plugins.append(extension_name)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/run.py
pylint/lint/run.py
416
generate_manpage
ref
function
self.linter.generate_manpage(__pkginfo__)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/run.py
pylint/lint/run.py
419
cb_help_message
def
function
def cb_help_message(self, option, optname, value, parser): """Optik callback for printing some help about a particular message.""" self.linter.msgs_store.help_message(utils._splitstrip(value)) sys.exit(0) def cb_full_documentation(self, option, optname, value, parser): """Optik callback for printing full documentation.""" print_full_documentation(self.linter) sys.exit(0) def cb_list_messages(self, option, optname, value, parser): """Optik callback for printing available messages.""" self.linter.msgs_store.list_messages() sys.exit(0) def cb_list_messages_enabled(self, option, optname, value, parser): """Optik callback for printing available messages.""" self.linter.list_messages_enabled() sys.exit(0) def cb_list_groups(self, *args, **kwargs): """List all the check groups that pylint knows about. These should be useful to know what check groups someone can disable or enable. """ for check in self.linter.get_checker_names(): print(check) sys.exit(0) def cb_verbose_mode(self, *args, **kwargs): self.verbose = _True def cb_enable_all_extensions(self, option_name: str, value: None) -> None: """Callback to load and enable all available extensions.""" for filename in os.listdir(os.path.dirname(extensions.__file__)): if filename.endswith(".py") and not filename.startswith("_"): extension_name = f"pylint.extensions.{filename[:-3]}" if extension_name not in self._plugins: self._plugins.append(extension_name)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/run.py
pylint/lint/run.py
421
help_message
ref
function
self.linter.msgs_store.help_message(utils._splitstrip(value))
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/run.py
pylint/lint/run.py
421
_splitstrip
ref
function
self.linter.msgs_store.help_message(utils._splitstrip(value))
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/run.py
pylint/lint/run.py
424
cb_full_documentation
def
function
def cb_full_documentation(self, option, optname, value, parser): """Optik callback for printing full documentation.""" print_full_documentation(self.linter) sys.exit(0) def cb_list_messages(self, option, optname, value, parser): """Optik callback for printing available messages.""" self.linter.msgs_store.list_messages() sys.exit(0) def cb_list_messages_enabled(self, option, optname, value, parser): """Optik callback for printing available messages.""" self.linter.list_messages_enabled() sys.exit(0) def cb_list_groups(self, *args, **kwargs): """List all the check groups that pylint knows about. These should be useful to know what check groups someone can disable or enable. """ for check in self.linter.get_checker_names(): print(check) sys.exit(0) def cb_verbose_mode(self, *args, **kwargs): self.verbose = _True def cb_enable_all_extensions(self, option_name: str, value: None) -> None: """Callback to load and enable all available extensions.""" for filename in os.listdir(os.path.dirname(extensions.__file__)): if filename.endswith(".py") and not filename.startswith("_"): extension_name = f"pylint.extensions.{filename[:-3]}" if extension_name not in self._plugins: self._plugins.append(extension_name)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/run.py
pylint/lint/run.py
426
print_full_documentation
ref
function
print_full_documentation(self.linter)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/run.py
pylint/lint/run.py
429
cb_list_messages
def
function
def cb_list_messages(self, option, optname, value, parser): """Optik callback for printing available messages.""" self.linter.msgs_store.list_messages() sys.exit(0) def cb_list_messages_enabled(self, option, optname, value, parser): """Optik callback for printing available messages.""" self.linter.list_messages_enabled() sys.exit(0) def cb_list_groups(self, *args, **kwargs): """List all the check groups that pylint knows about. These should be useful to know what check groups someone can disable or enable. """ for check in self.linter.get_checker_names(): print(check) sys.exit(0) def cb_verbose_mode(self, *args, **kwargs): self.verbose = _True def cb_enable_all_extensions(self, option_name: str, value: None) -> None: """Callback to load and enable all available extensions.""" for filename in os.listdir(os.path.dirname(extensions.__file__)): if filename.endswith(".py") and not filename.startswith("_"): extension_name = f"pylint.extensions.{filename[:-3]}" if extension_name not in self._plugins: self._plugins.append(extension_name)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/run.py
pylint/lint/run.py
431
list_messages
ref
function
self.linter.msgs_store.list_messages()
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/run.py
pylint/lint/run.py
434
cb_list_messages_enabled
def
function
def cb_list_messages_enabled(self, option, optname, value, parser): """Optik callback for printing available messages.""" self.linter.list_messages_enabled() sys.exit(0) def cb_list_groups(self, *args, **kwargs): """List all the check groups that pylint knows about. These should be useful to know what check groups someone can disable or enable. """ for check in self.linter.get_checker_names(): print(check) sys.exit(0) def cb_verbose_mode(self, *args, **kwargs): self.verbose = _True def cb_enable_all_extensions(self, option_name: str, value: None) -> None: """Callback to load and enable all available extensions.""" for filename in os.listdir(os.path.dirname(extensions.__file__)): if filename.endswith(".py") and not filename.startswith("_"): extension_name = f"pylint.extensions.{filename[:-3]}" if extension_name not in self._plugins: self._plugins.append(extension_name)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/run.py
pylint/lint/run.py
436
list_messages_enabled
ref
function
self.linter.list_messages_enabled()
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/run.py
pylint/lint/run.py
439
cb_list_groups
def
function
def cb_list_groups(self, *args, **kwargs): """List all the check groups that pylint knows about. These should be useful to know what check groups someone can disable or enable. """ for check in self.linter.get_checker_names(): print(check) sys.exit(0) def cb_verbose_mode(self, *args, **kwargs): self.verbose = _True def cb_enable_all_extensions(self, option_name: str, value: None) -> None: """Callback to load and enable all available extensions.""" for filename in os.listdir(os.path.dirname(extensions.__file__)): if filename.endswith(".py") and not filename.startswith("_"): extension_name = f"pylint.extensions.{filename[:-3]}" if extension_name not in self._plugins: self._plugins.append(extension_name)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/run.py
pylint/lint/run.py
445
get_checker_names
ref
function
for check in self.linter.get_checker_names():
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/run.py
pylint/lint/run.py
449
cb_verbose_mode
def
function
def cb_verbose_mode(self, *args, **kwargs): self.verbose = _True def cb_enable_all_extensions(self, option_name: str, value: None) -> None: """Callback to load and enable all available extensions.""" for filename in os.listdir(os.path.dirname(extensions.__file__)): if filename.endswith(".py") and not filename.startswith("_"): extension_name = f"pylint.extensions.{filename[:-3]}" if extension_name not in self._plugins: self._plugins.append(extension_name)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/run.py
pylint/lint/run.py
452
cb_enable_all_extensions
def
function
def cb_enable_all_extensions(self, option_name: str, value: None) -> None: """Callback to load and enable all available extensions.""" for filename in os.listdir(os.path.dirname(extensions.__file__)): if filename.endswith(".py") and not filename.startswith("_"): extension_name = f"pylint.extensions.{filename[:-3]}" if extension_name not in self._plugins: self._plugins.append(extension_name)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/run.py
pylint/lint/run.py
454
dirname
ref
function
for filename in os.listdir(os.path.dirname(extensions.__file__)):
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/utils.py
pylint/lint/utils.py
13
ArgumentPreprocessingError
def
class
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/utils.py
pylint/lint/utils.py
17
prepare_crash_report
def
function
def prepare_crash_report(ex: Exception, filepath: str, crash_file_path: str) -> Path: issue_template_path = ( Path(PYLINT_HOME) / datetime.now().strftime(str(crash_file_path)) ).resolve() with open(filepath, encoding="utf8") as f: file_content = f.read() template = "" if not issue_template_path.exists(): template = """\
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/utils.py
pylint/lint/utils.py
22
read
ref
function
file_content = f.read()
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/utils.py
pylint/lint/utils.py
54
write
ref
function
f.write(template)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/utils.py
pylint/lint/utils.py
56
write
ref
function
f.write("```\n")
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/utils.py
pylint/lint/utils.py
62
get_fatal_error_message
def
function
def get_fatal_error_message(filepath: str, issue_template_path: Path) -> str: return ( f"Fatal error while checking '{filepath}'. " f"Please open an issue in our bug tracker so we address this. " f"There is a pre-filled template that you can use in '{issue_template_path}'." )
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/utils.py
pylint/lint/utils.py
70
preprocess_options
def
function
def preprocess_options(args, search_for): """Look for some options (keys of <search_for>) which have to be processed before others values of <search_for> are callback functions to call when the option is found """ i = 0 while i < len(args): arg = args[i] if not arg.startswith("--"): i += 1 else: try: option, val = arg[2:].split("=", 1) except ValueError: option, val = arg[2:], None try: cb, takearg = search_for[option] except KeyError: i += 1 else: del args[i] if takearg and val is None: if i >= len(args) or args[i].startswith("-"): msg = f"Option {option} expects a value" raise ArgumentPreprocessingError(msg) val = args[i] del args[i] elif not takearg and val is not None: msg = f"Option {option} doesn't expects a value" raise ArgumentPreprocessingError(msg) cb(option, val)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/utils.py
pylint/lint/utils.py
96
ArgumentPreprocessingError
ref
function
raise ArgumentPreprocessingError(msg)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/utils.py
pylint/lint/utils.py
101
ArgumentPreprocessingError
ref
function
raise ArgumentPreprocessingError(msg)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/utils.py
pylint/lint/utils.py
102
cb
ref
function
cb(option, val)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/utils.py
pylint/lint/utils.py
105
_patch_sys_path
def
function
def _patch_sys_path(args): original = list(sys.path) changes = [] seen = set() for arg in args: path = get_python_path(arg) if path not in seen: changes.append(path) seen.add(path) sys.path[:] = changes + sys.path return original
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/utils.py
pylint/lint/utils.py
110
get_python_path
ref
function
path = get_python_path(arg)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/utils.py
pylint/lint/utils.py
120
fix_import_path
def
function
def fix_import_path(args): """Prepare 'sys.path' for running the linter checks. Within this context, each of the given arguments is importable. Paths are added to 'sys.path' in corresponding order to the arguments. We avoid adding duplicate directories to sys.path. `sys.path` is reset to its original value upon exiting this context. """ original = _patch_sys_path(args) try: yield finally: sys.path[:] = original
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/lint/utils.py
pylint/lint/utils.py
128
_patch_sys_path
ref
function
original = _patch_sys_path(args)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/message/message.py
pylint/message/message.py
33
Message
def
class
__new__ __new__ __new__ format
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/message/message.py
pylint/message/message.py
93
_asdict
ref
function
return template.format(**self._asdict())
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/message/message_definition.py
pylint/message/message_definition.py
16
MessageDefinition
def
class
__init__ check_msgid __repr__ __str__ may_be_emitted format_help check_message_definition
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/message/message_definition.py
pylint/message/message_definition.py
30
check_msgid
ref
function
self.check_msgid(msgid)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/message/message_definition.py
pylint/message/message_definition.py
41
check_msgid
ref
function
self.check_msgid(old_msgid)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/message/message_definition.py
pylint/message/message_definition.py
47
check_msgid
def
function
def check_msgid(msgid: str) -> None: if len(msgid) != 5: raise InvalidMessageError(f"Invalid message id {msgid!r}") if msgid[0] not in MSG_TYPES: raise InvalidMessageError(f"Bad message type {msgid[0]} in {msgid!r}") def __repr__(self) -> str: return f"MessageDefinition:{self.symbol} ({self.msgid})" def __str__(self) -> str: return f"{repr(self)}:\n{self.msg} {self.description}" def may_be_emitted(self) -> bool: """Return _True if message may be emitted using the current interpreter.""" if self.minversion is not None and self.minversion > sys.version_info: return _False if self.maxversion is not None and self.maxversion <= sys.version_info: return _False return _True def format_help(self, checkerref: bool = _False) -> str: """Return the help string for the given message id.""" desc = self.description if checkerref: desc += f" This message belongs to the {self.checker_name} checker." title = self.msg if self.minversion or self.maxversion: restr = [] if self.minversion: restr.append(f"< {'.'.join(str(n) for n in self.minversion)}") if self.maxversion: restr.append(f">= {'.'.join(str(n) for n in self.maxversion)}") restriction = " or ".join(restr) if checkerref: desc += f" It can't be emitted when using Python {restriction}." else: desc += ( f" This message can't be emitted when using Python {restriction}." ) msg_help = normalize_text(" ".join(desc.split()), indent=" ") message_id = f"{self.symbol} ({self.msgid})" if title != "%s": title = title.splitlines()[0] return f":{message_id}: *{title.rstrip(' ')}*\n{msg_help}" return f":{message_id}:\n{msg_help}" def check_message_definition( self, line: Optional[int], node: Optional[nodes.NodeNG] ) -> None: """Check MessageDefinition for possible errors.""" if self.msgid[0] not in _SCOPE_EXEMPT: # Fatal messages and reports are special, the node/scope distinction # does not apply to them. if self.scope == WarningScope.LINE: if line is None: raise InvalidMessageError( f"Message {self.msgid} must provide line, got None" ) if node is not None: raise InvalidMessageError( f"Message {self.msgid} must only provide line, " f"got line={line}, node={node}" ) elif self.scope == WarningScope.NODE: # Node-based warnings may provide an override line. if node is None: raise InvalidMessageError( f"Message {self.msgid} must provide Node, got None" )
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/message/message_definition.py
pylint/message/message_definition.py
49
InvalidMessageError
ref
function
raise InvalidMessageError(f"Invalid message id {msgid!r}")
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/message/message_definition.py
pylint/message/message_definition.py
51
InvalidMessageError
ref
function
raise InvalidMessageError(f"Bad message type {msgid[0]} in {msgid!r}")
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/message/message_definition.py
pylint/message/message_definition.py
59
may_be_emitted
def
function
def may_be_emitted(self) -> bool: """Return _True if message may be emitted using the current interpreter.""" if self.minversion is not None and self.minversion > sys.version_info: return _False if self.maxversion is not None and self.maxversion <= sys.version_info: return _False return _True def format_help(self, checkerref: bool = _False) -> str: """Return the help string for the given message id.""" desc = self.description if checkerref: desc += f" This message belongs to the {self.checker_name} checker." title = self.msg if self.minversion or self.maxversion: restr = [] if self.minversion: restr.append(f"< {'.'.join(str(n) for n in self.minversion)}") if self.maxversion: restr.append(f">= {'.'.join(str(n) for n in self.maxversion)}") restriction = " or ".join(restr) if checkerref: desc += f" It can't be emitted when using Python {restriction}." else: desc += ( f" This message can't be emitted when using Python {restriction}." ) msg_help = normalize_text(" ".join(desc.split()), indent=" ") message_id = f"{self.symbol} ({self.msgid})" if title != "%s": title = title.splitlines()[0] return f":{message_id}: *{title.rstrip(' ')}*\n{msg_help}" return f":{message_id}:\n{msg_help}" def check_message_definition( self, line: Optional[int], node: Optional[nodes.NodeNG] ) -> None: """Check MessageDefinition for possible errors.""" if self.msgid[0] not in _SCOPE_EXEMPT: # Fatal messages and reports are special, the node/scope distinction # does not apply to them. if self.scope == WarningScope.LINE: if line is None: raise InvalidMessageError( f"Message {self.msgid} must provide line, got None" ) if node is not None: raise InvalidMessageError( f"Message {self.msgid} must only provide line, " f"got line={line}, node={node}" ) elif self.scope == WarningScope.NODE: # Node-based warnings may provide an override line. if node is None: raise InvalidMessageError( f"Message {self.msgid} must provide Node, got None" )
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/message/message_definition.py
pylint/message/message_definition.py
67
format_help
def
function
null
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/message/message_definition.py
pylint/message/message_definition.py
86
normalize_text
ref
function
msg_help = normalize_text(" ".join(desc.split()), indent=" ")
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/message/message_definition.py
pylint/message/message_definition.py
93
check_message_definition
def
function
def check_message_definition( self, line: Optional[int], node: Optional[nodes.NodeNG] ) -> None: """Check MessageDefinition for possible errors.""" if self.msgid[0] not in _SCOPE_EXEMPT: # Fatal messages and reports are special, the node/scope distinction # does not apply to them. if self.scope == WarningScope.LINE: if line is None: raise InvalidMessageError( f"Message {self.msgid} must provide line, got None" ) if node is not None: raise InvalidMessageError( f"Message {self.msgid} must only provide line, " f"got line={line}, node={node}" ) elif self.scope == WarningScope.NODE: # Node-based warnings may provide an override line. if node is None: raise InvalidMessageError( f"Message {self.msgid} must provide Node, got None" )
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/message/message_definition.py
pylint/message/message_definition.py
102
InvalidMessageError
ref
function
raise InvalidMessageError(
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/message/message_definition.py
pylint/message/message_definition.py
106
InvalidMessageError
ref
function
raise InvalidMessageError(
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/message/message_definition.py
pylint/message/message_definition.py
113
InvalidMessageError
ref
function
raise InvalidMessageError(
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/message/message_definition_store.py
pylint/message/message_definition_store.py
15
MessageDefinitionStore
def
class
__init__ messages register_messages_from_checker register_message get_message_definitions get_msg_display_string help_message list_messages find_emittable_messages
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/message/message_definition_store.py
pylint/message/message_definition_store.py
22
MessageIdStore
ref
function
self.message_id_store: MessageIdStore = MessageIdStore()
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/message/message_definition_store.py
pylint/message/message_definition_store.py
31
messages
def
function
def messages(self) -> ValuesView[MessageDefinition]: """The list of all active messages.""" return self._messages_definitions.values() def register_messages_from_checker(self, checker: "BaseChecker") -> None: """Register all messages definitions from a checker.""" checker.check_consistency() for message in checker.messages: self.register_message(message) def register_message(self, message: MessageDefinition) -> None: """Register a MessageDefinition with consistency in mind.""" self.message_id_store.register_message_definition( message.msgid, message.symbol, message.old_names ) self._messages_definitions[message.msgid] = message self._msgs_by_category[message.msgid[0]].append(message.msgid) # We disable the message here because MessageDefinitionStore is only # initialized once and due to the size of the class does not run the # risk of creating a large memory leak. # See discussion in: https://github.com/PyCQA/pylint/pull/5673 @functools.lru_cache() # pylint: disable=lru-cache-decorating-method def get_message_definitions(self, msgid_or_symbol: str) -> List[MessageDefinition]: """Returns the Message definition for either a numeric or symbolic id. The cache has no limit as its size will likely stay minimal. For each message we store about 1000 characters, so even if we would have 1000 messages the cache would only take up ~= 1 Mb. """ return [ self._messages_definitions[m] for m in self.message_id_store.get_active_msgids(msgid_or_symbol) ] def get_msg_display_string(self, msgid_or_symbol: str) -> str: """Generates a user-consumable representation of a message.""" message_definitions = self.get_message_definitions(msgid_or_symbol) if len(message_definitions) == 1: return repr(message_definitions[0].symbol) return repr([md.symbol for md in message_definitions]) def help_message(self, msgids_or_symbols: List[str]) -> None: """Display help messages for the given message identifiers.""" for msgids_or_symbol in msgids_or_symbols: try: for message_definition in self.get_message_definitions( msgids_or_symbol ): print(message_definition.format_help(checkerref=_True)) print("") except UnknownMessageError as ex: print(ex) print("") continue def list_messages(self) -> None: """Output full messages list documentation in ReST format.""" emittable, non_emittable = self.find_emittable_messages() print("Emittable messages with current interpreter:") for msg in emittable: print(msg.format_help(checkerref=_False)) print("\nNon-emittable messages with current interpreter:") for msg in non_emittable: print(msg.format_help(checkerref=_False)) print("") def find_emittable_messages( self, ) -> Tuple[List[MessageDefinition], List[MessageDefinition]]: """Finds all emittable and non-emittable messages.""" messages = sorted(self._messages_definitions.values(), key=lambda m: m.msgid) emittable = [] non_emittable = [] for message in messages: if message.may_be_emitted(): emittable.append(message) else: non_emittable.append(message) return emittable, non_emittable
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/message/message_definition_store.py
pylint/message/message_definition_store.py
35
register_messages_from_checker
def
function
def register_messages_from_checker(self, checker: "BaseChecker") -> None: """Register all messages definitions from a checker.""" checker.check_consistency() for message in checker.messages: self.register_message(message) def register_message(self, message: MessageDefinition) -> None: """Register a MessageDefinition with consistency in mind.""" self.message_id_store.register_message_definition( message.msgid, message.symbol, message.old_names ) self._messages_definitions[message.msgid] = message self._msgs_by_category[message.msgid[0]].append(message.msgid) # We disable the message here because MessageDefinitionStore is only # initialized once and due to the size of the class does not run the # risk of creating a large memory leak. # See discussion in: https://github.com/PyCQA/pylint/pull/5673 @functools.lru_cache() # pylint: disable=lru-cache-decorating-method def get_message_definitions(self, msgid_or_symbol: str) -> List[MessageDefinition]: """Returns the Message definition for either a numeric or symbolic id. The cache has no limit as its size will likely stay minimal. For each message we store about 1000 characters, so even if we would have 1000 messages the cache would only take up ~= 1 Mb. """ return [ self._messages_definitions[m] for m in self.message_id_store.get_active_msgids(msgid_or_symbol) ] def get_msg_display_string(self, msgid_or_symbol: str) -> str: """Generates a user-consumable representation of a message.""" message_definitions = self.get_message_definitions(msgid_or_symbol) if len(message_definitions) == 1: return repr(message_definitions[0].symbol) return repr([md.symbol for md in message_definitions]) def help_message(self, msgids_or_symbols: List[str]) -> None: """Display help messages for the given message identifiers.""" for msgids_or_symbol in msgids_or_symbols: try: for message_definition in self.get_message_definitions( msgids_or_symbol ): print(message_definition.format_help(checkerref=_True)) print("") except UnknownMessageError as ex: print(ex) print("") continue def list_messages(self) -> None: """Output full messages list documentation in ReST format.""" emittable, non_emittable = self.find_emittable_messages() print("Emittable messages with current interpreter:") for msg in emittable: print(msg.format_help(checkerref=_False)) print("\nNon-emittable messages with current interpreter:") for msg in non_emittable: print(msg.format_help(checkerref=_False)) print("") def find_emittable_messages( self, ) -> Tuple[List[MessageDefinition], List[MessageDefinition]]: """Finds all emittable and non-emittable messages.""" messages = sorted(self._messages_definitions.values(), key=lambda m: m.msgid) emittable = [] non_emittable = [] for message in messages: if message.may_be_emitted(): emittable.append(message) else: non_emittable.append(message) return emittable, non_emittable
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/message/message_definition_store.py
pylint/message/message_definition_store.py
37
check_consistency
ref
function
checker.check_consistency()
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/message/message_definition_store.py
pylint/message/message_definition_store.py
39
register_message
ref
function
self.register_message(message)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/message/message_definition_store.py
pylint/message/message_definition_store.py
41
register_message
def
function
def register_message(self, message: MessageDefinition) -> None: """Register a MessageDefinition with consistency in mind.""" self.message_id_store.register_message_definition( message.msgid, message.symbol, message.old_names ) self._messages_definitions[message.msgid] = message self._msgs_by_category[message.msgid[0]].append(message.msgid) # We disable the message here because MessageDefinitionStore is only # initialized once and due to the size of the class does not run the # risk of creating a large memory leak. # See discussion in: https://github.com/PyCQA/pylint/pull/5673 @functools.lru_cache() # pylint: disable=lru-cache-decorating-method def get_message_definitions(self, msgid_or_symbol: str) -> List[MessageDefinition]: """Returns the Message definition for either a numeric or symbolic id. The cache has no limit as its size will likely stay minimal. For each message we store about 1000 characters, so even if we would have 1000 messages the cache would only take up ~= 1 Mb. """ return [ self._messages_definitions[m] for m in self.message_id_store.get_active_msgids(msgid_or_symbol) ] def get_msg_display_string(self, msgid_or_symbol: str) -> str: """Generates a user-consumable representation of a message.""" message_definitions = self.get_message_definitions(msgid_or_symbol) if len(message_definitions) == 1: return repr(message_definitions[0].symbol) return repr([md.symbol for md in message_definitions]) def help_message(self, msgids_or_symbols: List[str]) -> None: """Display help messages for the given message identifiers.""" for msgids_or_symbol in msgids_or_symbols: try: for message_definition in self.get_message_definitions( msgids_or_symbol ): print(message_definition.format_help(checkerref=_True)) print("") except UnknownMessageError as ex: print(ex) print("") continue def list_messages(self) -> None: """Output full messages list documentation in ReST format.""" emittable, non_emittable = self.find_emittable_messages() print("Emittable messages with current interpreter:") for msg in emittable: print(msg.format_help(checkerref=_False)) print("\nNon-emittable messages with current interpreter:") for msg in non_emittable: print(msg.format_help(checkerref=_False)) print("") def find_emittable_messages( self, ) -> Tuple[List[MessageDefinition], List[MessageDefinition]]: """Finds all emittable and non-emittable messages.""" messages = sorted(self._messages_definitions.values(), key=lambda m: m.msgid) emittable = [] non_emittable = [] for message in messages: if message.may_be_emitted(): emittable.append(message) else: non_emittable.append(message) return emittable, non_emittable
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/message/message_definition_store.py
pylint/message/message_definition_store.py
43
register_message_definition
ref
function
self.message_id_store.register_message_definition(
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/message/message_definition_store.py
pylint/message/message_definition_store.py
54
get_message_definitions
def
function
def get_message_definitions(self, msgid_or_symbol: str) -> List[MessageDefinition]: """Returns the Message definition for either a numeric or symbolic id. The cache has no limit as its size will likely stay minimal. For each message we store about 1000 characters, so even if we would have 1000 messages the cache would only take up ~= 1 Mb. """ return [ self._messages_definitions[m] for m in self.message_id_store.get_active_msgids(msgid_or_symbol) ] def get_msg_display_string(self, msgid_or_symbol: str) -> str: """Generates a user-consumable representation of a message.""" message_definitions = self.get_message_definitions(msgid_or_symbol) if len(message_definitions) == 1: return repr(message_definitions[0].symbol) return repr([md.symbol for md in message_definitions]) def help_message(self, msgids_or_symbols: List[str]) -> None: """Display help messages for the given message identifiers.""" for msgids_or_symbol in msgids_or_symbols: try: for message_definition in self.get_message_definitions( msgids_or_symbol ): print(message_definition.format_help(checkerref=_True)) print("") except UnknownMessageError as ex: print(ex) print("") continue def list_messages(self) -> None: """Output full messages list documentation in ReST format.""" emittable, non_emittable = self.find_emittable_messages() print("Emittable messages with current interpreter:") for msg in emittable: print(msg.format_help(checkerref=_False)) print("\nNon-emittable messages with current interpreter:") for msg in non_emittable: print(msg.format_help(checkerref=_False)) print("") def find_emittable_messages( self, ) -> Tuple[List[MessageDefinition], List[MessageDefinition]]: """Finds all emittable and non-emittable messages.""" messages = sorted(self._messages_definitions.values(), key=lambda m: m.msgid) emittable = [] non_emittable = [] for message in messages: if message.may_be_emitted(): emittable.append(message) else: non_emittable.append(message) return emittable, non_emittable
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/message/message_definition_store.py
pylint/message/message_definition_store.py
63
get_active_msgids
ref
function
for m in self.message_id_store.get_active_msgids(msgid_or_symbol)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/message/message_definition_store.py
pylint/message/message_definition_store.py
66
get_msg_display_string
def
function
def get_msg_display_string(self, msgid_or_symbol: str) -> str: """Generates a user-consumable representation of a message.""" message_definitions = self.get_message_definitions(msgid_or_symbol) if len(message_definitions) == 1: return repr(message_definitions[0].symbol) return repr([md.symbol for md in message_definitions]) def help_message(self, msgids_or_symbols: List[str]) -> None: """Display help messages for the given message identifiers.""" for msgids_or_symbol in msgids_or_symbols: try: for message_definition in self.get_message_definitions( msgids_or_symbol ): print(message_definition.format_help(checkerref=_True)) print("") except UnknownMessageError as ex: print(ex) print("") continue def list_messages(self) -> None: """Output full messages list documentation in ReST format.""" emittable, non_emittable = self.find_emittable_messages() print("Emittable messages with current interpreter:") for msg in emittable: print(msg.format_help(checkerref=_False)) print("\nNon-emittable messages with current interpreter:") for msg in non_emittable: print(msg.format_help(checkerref=_False)) print("") def find_emittable_messages( self, ) -> Tuple[List[MessageDefinition], List[MessageDefinition]]: """Finds all emittable and non-emittable messages.""" messages = sorted(self._messages_definitions.values(), key=lambda m: m.msgid) emittable = [] non_emittable = [] for message in messages: if message.may_be_emitted(): emittable.append(message) else: non_emittable.append(message) return emittable, non_emittable
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/message/message_definition_store.py
pylint/message/message_definition_store.py
68
get_message_definitions
ref
function
message_definitions = self.get_message_definitions(msgid_or_symbol)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/message/message_definition_store.py
pylint/message/message_definition_store.py
73
help_message
def
function
def help_message(self, msgids_or_symbols: List[str]) -> None: """Display help messages for the given message identifiers.""" for msgids_or_symbol in msgids_or_symbols: try: for message_definition in self.get_message_definitions( msgids_or_symbol ): print(message_definition.format_help(checkerref=_True)) print("") except UnknownMessageError as ex: print(ex) print("") continue def list_messages(self) -> None: """Output full messages list documentation in ReST format.""" emittable, non_emittable = self.find_emittable_messages() print("Emittable messages with current interpreter:") for msg in emittable: print(msg.format_help(checkerref=_False)) print("\nNon-emittable messages with current interpreter:") for msg in non_emittable: print(msg.format_help(checkerref=_False)) print("") def find_emittable_messages( self, ) -> Tuple[List[MessageDefinition], List[MessageDefinition]]: """Finds all emittable and non-emittable messages.""" messages = sorted(self._messages_definitions.values(), key=lambda m: m.msgid) emittable = [] non_emittable = [] for message in messages: if message.may_be_emitted(): emittable.append(message) else: non_emittable.append(message) return emittable, non_emittable
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/message/message_definition_store.py
pylint/message/message_definition_store.py
77
get_message_definitions
ref
function
for message_definition in self.get_message_definitions(
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/message/message_definition_store.py
pylint/message/message_definition_store.py
80
format_help
ref
function
print(message_definition.format_help(checkerref=True))
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/message/message_definition_store.py
pylint/message/message_definition_store.py
87
list_messages
def
function
def list_messages(self) -> None: """Output full messages list documentation in ReST format.""" emittable, non_emittable = self.find_emittable_messages() print("Emittable messages with current interpreter:") for msg in emittable: print(msg.format_help(checkerref=_False)) print("\nNon-emittable messages with current interpreter:") for msg in non_emittable: print(msg.format_help(checkerref=_False)) print("") def find_emittable_messages( self, ) -> Tuple[List[MessageDefinition], List[MessageDefinition]]: """Finds all emittable and non-emittable messages.""" messages = sorted(self._messages_definitions.values(), key=lambda m: m.msgid) emittable = [] non_emittable = [] for message in messages: if message.may_be_emitted(): emittable.append(message) else: non_emittable.append(message) return emittable, non_emittable
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/message/message_definition_store.py
pylint/message/message_definition_store.py
89
find_emittable_messages
ref
function
emittable, non_emittable = self.find_emittable_messages()
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/message/message_definition_store.py
pylint/message/message_definition_store.py
92
format_help
ref
function
print(msg.format_help(checkerref=False))
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/message/message_definition_store.py
pylint/message/message_definition_store.py
95
format_help
ref
function
print(msg.format_help(checkerref=False))
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/message/message_definition_store.py
pylint/message/message_definition_store.py
98
find_emittable_messages
def
function
def find_emittable_messages( self, ) -> Tuple[List[MessageDefinition], List[MessageDefinition]]: """Finds all emittable and non-emittable messages.""" messages = sorted(self._messages_definitions.values(), key=lambda m: m.msgid) emittable = [] non_emittable = [] for message in messages: if message.may_be_emitted(): emittable.append(message) else: non_emittable.append(message) return emittable, non_emittable
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/message/message_definition_store.py
pylint/message/message_definition_store.py
106
may_be_emitted
ref
function
if message.may_be_emitted():
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/message/message_id_store.py
pylint/message/message_id_store.py
7
MessageIdStore
def
class
__init__ __len__ __repr__ get_symbol get_msgid register_message_definition add_msgid_and_symbol add_legacy_msgid_and_symbol check_msgid_and_symbol _raise_duplicate_symbol _raise_duplicate_msgid get_active_msgids
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/message/message_id_store.py
pylint/message/message_id_store.py
27
get_symbol
def
function
def get_symbol(self, msgid: str) -> str: try: return self.__msgid_to_symbol[msgid.upper()] except KeyError as e: msg = f"'{msgid}' is not stored in the message store." raise UnknownMessageError(msg) from e def get_msgid(self, symbol: str) -> str: try: return self.__symbol_to_msgid[symbol] except KeyError as e: msg = f"'{symbol}' is not stored in the message store." raise UnknownMessageError(msg) from e def register_message_definition( self, msgid: str, symbol: str, old_names: List[Tuple[str, str]] ) -> None: self.check_msgid_and_symbol(msgid, symbol) self.add_msgid_and_symbol(msgid, symbol) for old_msgid, old_symbol in old_names: self.check_msgid_and_symbol(old_msgid, old_symbol) self.add_legacy_msgid_and_symbol(old_msgid, old_symbol, msgid) def add_msgid_and_symbol(self, msgid: str, symbol: str) -> None: """Add valid message id. There is a little duplication with add_legacy_msgid_and_symbol to avoid a function call, this is called a lot at initialization. """ self.__msgid_to_symbol[msgid] = symbol self.__symbol_to_msgid[symbol] = msgid def add_legacy_msgid_and_symbol( self, msgid: str, symbol: str, new_msgid: str ) -> None: """Add valid legacy message id. There is a little duplication with add_msgid_and_symbol to avoid a function call, this is called a lot at initialization. """ self.__msgid_to_symbol[msgid] = symbol self.__symbol_to_msgid[symbol] = msgid existing_old_names = self.__old_names.get(msgid, []) existing_old_names.append(new_msgid) self.__old_names[msgid] = existing_old_names def check_msgid_and_symbol(self, msgid: str, symbol: str) -> None: existing_msgid: Optional[str] = self.__symbol_to_msgid.get(symbol) existing_symbol: Optional[str] = self.__msgid_to_symbol.get(msgid) if existing_symbol is None and existing_msgid is None: return # both symbol and msgid are usable if existing_msgid is not None: if existing_msgid != msgid: self._raise_duplicate_msgid(symbol, msgid, existing_msgid) if existing_symbol and existing_symbol != symbol: # See https://github.com/python/mypy/issues/10559 self._raise_duplicate_symbol(msgid, symbol, existing_symbol) @staticmethod def _raise_duplicate_symbol(msgid: str, symbol: str, other_symbol: str) -> NoReturn: """Raise an error when a symbol is duplicated.""" symbols = [symbol, other_symbol] symbols.sort() error_message = f"Message id '{msgid}' cannot have both " error_message += f"'{symbols[0]}' and '{symbols[1]}' as symbolic name." raise InvalidMessageError(error_message) @staticmethod def _raise_duplicate_msgid(symbol: str, msgid: str, other_msgid: str) -> NoReturn: """Raise an error when a msgid is duplicated.""" msgids = [msgid, other_msgid] msgids.sort() error_message = ( f"Message symbol '{symbol}' cannot be used for " f"'{msgids[0]}' and '{msgids[1]}' at the same time." f" If you're creating an 'old_names' use 'old-{symbol}' as the old symbol." ) raise InvalidMessageError(error_message) def get_active_msgids(self, msgid_or_symbol: str) -> List[str]: """Return msgids but the input can be a symbol. self.__active_msgids is used to implement a primitive cache for this function. """ try: return self.__active_msgids[msgid_or_symbol] except KeyError: pass # If we don't have a cached value yet we compute it msgid: Optional[str] if msgid_or_symbol[1:].isdigit(): # Only msgid can have a digit as second letter msgid = msgid_or_symbol.upper() symbol = self.__msgid_to_symbol.get(msgid) else: msgid = self.__symbol_to_msgid.get(msgid_or_symbol) symbol = msgid_or_symbol if not msgid or not symbol: error_msg = f"No such message id or symbol '{msgid_or_symbol}'." raise UnknownMessageError(error_msg) ids = self.__old_names.get(msgid, [msgid]) # Add to cache self.__active_msgids[msgid_or_symbol] = ids return ids
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/message/message_id_store.py
pylint/message/message_id_store.py
32
UnknownMessageError
ref
function
raise UnknownMessageError(msg) from e
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/message/message_id_store.py
pylint/message/message_id_store.py
34
get_msgid
def
function
def get_msgid(self, symbol: str) -> str: try: return self.__symbol_to_msgid[symbol] except KeyError as e: msg = f"'{symbol}' is not stored in the message store." raise UnknownMessageError(msg) from e def register_message_definition( self, msgid: str, symbol: str, old_names: List[Tuple[str, str]] ) -> None: self.check_msgid_and_symbol(msgid, symbol) self.add_msgid_and_symbol(msgid, symbol) for old_msgid, old_symbol in old_names: self.check_msgid_and_symbol(old_msgid, old_symbol) self.add_legacy_msgid_and_symbol(old_msgid, old_symbol, msgid) def add_msgid_and_symbol(self, msgid: str, symbol: str) -> None: """Add valid message id. There is a little duplication with add_legacy_msgid_and_symbol to avoid a function call, this is called a lot at initialization. """ self.__msgid_to_symbol[msgid] = symbol self.__symbol_to_msgid[symbol] = msgid def add_legacy_msgid_and_symbol( self, msgid: str, symbol: str, new_msgid: str ) -> None: """Add valid legacy message id. There is a little duplication with add_msgid_and_symbol to avoid a function call, this is called a lot at initialization. """ self.__msgid_to_symbol[msgid] = symbol self.__symbol_to_msgid[symbol] = msgid existing_old_names = self.__old_names.get(msgid, []) existing_old_names.append(new_msgid) self.__old_names[msgid] = existing_old_names def check_msgid_and_symbol(self, msgid: str, symbol: str) -> None: existing_msgid: Optional[str] = self.__symbol_to_msgid.get(symbol) existing_symbol: Optional[str] = self.__msgid_to_symbol.get(msgid) if existing_symbol is None and existing_msgid is None: return # both symbol and msgid are usable if existing_msgid is not None: if existing_msgid != msgid: self._raise_duplicate_msgid(symbol, msgid, existing_msgid) if existing_symbol and existing_symbol != symbol: # See https://github.com/python/mypy/issues/10559 self._raise_duplicate_symbol(msgid, symbol, existing_symbol) @staticmethod def _raise_duplicate_symbol(msgid: str, symbol: str, other_symbol: str) -> NoReturn: """Raise an error when a symbol is duplicated.""" symbols = [symbol, other_symbol] symbols.sort() error_message = f"Message id '{msgid}' cannot have both " error_message += f"'{symbols[0]}' and '{symbols[1]}' as symbolic name." raise InvalidMessageError(error_message) @staticmethod def _raise_duplicate_msgid(symbol: str, msgid: str, other_msgid: str) -> NoReturn: """Raise an error when a msgid is duplicated.""" msgids = [msgid, other_msgid] msgids.sort() error_message = ( f"Message symbol '{symbol}' cannot be used for " f"'{msgids[0]}' and '{msgids[1]}' at the same time." f" If you're creating an 'old_names' use 'old-{symbol}' as the old symbol." ) raise InvalidMessageError(error_message) def get_active_msgids(self, msgid_or_symbol: str) -> List[str]: """Return msgids but the input can be a symbol. self.__active_msgids is used to implement a primitive cache for this function. """ try: return self.__active_msgids[msgid_or_symbol] except KeyError: pass # If we don't have a cached value yet we compute it msgid: Optional[str] if msgid_or_symbol[1:].isdigit(): # Only msgid can have a digit as second letter msgid = msgid_or_symbol.upper() symbol = self.__msgid_to_symbol.get(msgid) else: msgid = self.__symbol_to_msgid.get(msgid_or_symbol) symbol = msgid_or_symbol if not msgid or not symbol: error_msg = f"No such message id or symbol '{msgid_or_symbol}'." raise UnknownMessageError(error_msg) ids = self.__old_names.get(msgid, [msgid]) # Add to cache self.__active_msgids[msgid_or_symbol] = ids return ids
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/message/message_id_store.py
pylint/message/message_id_store.py
39
UnknownMessageError
ref
function
raise UnknownMessageError(msg) from e
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/message/message_id_store.py
pylint/message/message_id_store.py
41
register_message_definition
def
function
def register_message_definition( self, msgid: str, symbol: str, old_names: List[Tuple[str, str]] ) -> None: self.check_msgid_and_symbol(msgid, symbol) self.add_msgid_and_symbol(msgid, symbol) for old_msgid, old_symbol in old_names: self.check_msgid_and_symbol(old_msgid, old_symbol) self.add_legacy_msgid_and_symbol(old_msgid, old_symbol, msgid) def add_msgid_and_symbol(self, msgid: str, symbol: str) -> None: """Add valid message id. There is a little duplication with add_legacy_msgid_and_symbol to avoid a function call, this is called a lot at initialization. """ self.__msgid_to_symbol[msgid] = symbol self.__symbol_to_msgid[symbol] = msgid def add_legacy_msgid_and_symbol( self, msgid: str, symbol: str, new_msgid: str ) -> None: """Add valid legacy message id. There is a little duplication with add_msgid_and_symbol to avoid a function call, this is called a lot at initialization. """ self.__msgid_to_symbol[msgid] = symbol self.__symbol_to_msgid[symbol] = msgid existing_old_names = self.__old_names.get(msgid, []) existing_old_names.append(new_msgid) self.__old_names[msgid] = existing_old_names def check_msgid_and_symbol(self, msgid: str, symbol: str) -> None: existing_msgid: Optional[str] = self.__symbol_to_msgid.get(symbol) existing_symbol: Optional[str] = self.__msgid_to_symbol.get(msgid) if existing_symbol is None and existing_msgid is None: return # both symbol and msgid are usable if existing_msgid is not None: if existing_msgid != msgid: self._raise_duplicate_msgid(symbol, msgid, existing_msgid) if existing_symbol and existing_symbol != symbol: # See https://github.com/python/mypy/issues/10559 self._raise_duplicate_symbol(msgid, symbol, existing_symbol) @staticmethod def _raise_duplicate_symbol(msgid: str, symbol: str, other_symbol: str) -> NoReturn: """Raise an error when a symbol is duplicated.""" symbols = [symbol, other_symbol] symbols.sort() error_message = f"Message id '{msgid}' cannot have both " error_message += f"'{symbols[0]}' and '{symbols[1]}' as symbolic name." raise InvalidMessageError(error_message) @staticmethod def _raise_duplicate_msgid(symbol: str, msgid: str, other_msgid: str) -> NoReturn: """Raise an error when a msgid is duplicated.""" msgids = [msgid, other_msgid] msgids.sort() error_message = ( f"Message symbol '{symbol}' cannot be used for " f"'{msgids[0]}' and '{msgids[1]}' at the same time." f" If you're creating an 'old_names' use 'old-{symbol}' as the old symbol." ) raise InvalidMessageError(error_message) def get_active_msgids(self, msgid_or_symbol: str) -> List[str]: """Return msgids but the input can be a symbol. self.__active_msgids is used to implement a primitive cache for this function. """ try: return self.__active_msgids[msgid_or_symbol] except KeyError: pass # If we don't have a cached value yet we compute it msgid: Optional[str] if msgid_or_symbol[1:].isdigit(): # Only msgid can have a digit as second letter msgid = msgid_or_symbol.upper() symbol = self.__msgid_to_symbol.get(msgid) else: msgid = self.__symbol_to_msgid.get(msgid_or_symbol) symbol = msgid_or_symbol if not msgid or not symbol: error_msg = f"No such message id or symbol '{msgid_or_symbol}'." raise UnknownMessageError(error_msg) ids = self.__old_names.get(msgid, [msgid]) # Add to cache self.__active_msgids[msgid_or_symbol] = ids return ids
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/message/message_id_store.py
pylint/message/message_id_store.py
44
check_msgid_and_symbol
ref
function
self.check_msgid_and_symbol(msgid, symbol)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/message/message_id_store.py
pylint/message/message_id_store.py
45
add_msgid_and_symbol
ref
function
self.add_msgid_and_symbol(msgid, symbol)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/message/message_id_store.py
pylint/message/message_id_store.py
47
check_msgid_and_symbol
ref
function
self.check_msgid_and_symbol(old_msgid, old_symbol)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/message/message_id_store.py
pylint/message/message_id_store.py
48
add_legacy_msgid_and_symbol
ref
function
self.add_legacy_msgid_and_symbol(old_msgid, old_symbol, msgid)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/message/message_id_store.py
pylint/message/message_id_store.py
50
add_msgid_and_symbol
def
function
def add_msgid_and_symbol(self, msgid: str, symbol: str) -> None: """Add valid message id. There is a little duplication with add_legacy_msgid_and_symbol to avoid a function call, this is called a lot at initialization. """ self.__msgid_to_symbol[msgid] = symbol self.__symbol_to_msgid[symbol] = msgid def add_legacy_msgid_and_symbol( self, msgid: str, symbol: str, new_msgid: str ) -> None: """Add valid legacy message id. There is a little duplication with add_msgid_and_symbol to avoid a function call, this is called a lot at initialization. """ self.__msgid_to_symbol[msgid] = symbol self.__symbol_to_msgid[symbol] = msgid existing_old_names = self.__old_names.get(msgid, []) existing_old_names.append(new_msgid) self.__old_names[msgid] = existing_old_names def check_msgid_and_symbol(self, msgid: str, symbol: str) -> None: existing_msgid: Optional[str] = self.__symbol_to_msgid.get(symbol) existing_symbol: Optional[str] = self.__msgid_to_symbol.get(msgid) if existing_symbol is None and existing_msgid is None: return # both symbol and msgid are usable if existing_msgid is not None: if existing_msgid != msgid: self._raise_duplicate_msgid(symbol, msgid, existing_msgid) if existing_symbol and existing_symbol != symbol: # See https://github.com/python/mypy/issues/10559 self._raise_duplicate_symbol(msgid, symbol, existing_symbol) @staticmethod def _raise_duplicate_symbol(msgid: str, symbol: str, other_symbol: str) -> NoReturn: """Raise an error when a symbol is duplicated.""" symbols = [symbol, other_symbol] symbols.sort() error_message = f"Message id '{msgid}' cannot have both " error_message += f"'{symbols[0]}' and '{symbols[1]}' as symbolic name." raise InvalidMessageError(error_message) @staticmethod def _raise_duplicate_msgid(symbol: str, msgid: str, other_msgid: str) -> NoReturn: """Raise an error when a msgid is duplicated.""" msgids = [msgid, other_msgid] msgids.sort() error_message = ( f"Message symbol '{symbol}' cannot be used for " f"'{msgids[0]}' and '{msgids[1]}' at the same time." f" If you're creating an 'old_names' use 'old-{symbol}' as the old symbol." ) raise InvalidMessageError(error_message) def get_active_msgids(self, msgid_or_symbol: str) -> List[str]: """Return msgids but the input can be a symbol. self.__active_msgids is used to implement a primitive cache for this function. """ try: return self.__active_msgids[msgid_or_symbol] except KeyError: pass # If we don't have a cached value yet we compute it msgid: Optional[str] if msgid_or_symbol[1:].isdigit(): # Only msgid can have a digit as second letter msgid = msgid_or_symbol.upper() symbol = self.__msgid_to_symbol.get(msgid) else: msgid = self.__symbol_to_msgid.get(msgid_or_symbol) symbol = msgid_or_symbol if not msgid or not symbol: error_msg = f"No such message id or symbol '{msgid_or_symbol}'." raise UnknownMessageError(error_msg) ids = self.__old_names.get(msgid, [msgid]) # Add to cache self.__active_msgids[msgid_or_symbol] = ids return ids
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/message/message_id_store.py
pylint/message/message_id_store.py
59
add_legacy_msgid_and_symbol
def
function
def add_legacy_msgid_and_symbol( self, msgid: str, symbol: str, new_msgid: str ) -> None: """Add valid legacy message id. There is a little duplication with add_msgid_and_symbol to avoid a function call, this is called a lot at initialization. """ self.__msgid_to_symbol[msgid] = symbol self.__symbol_to_msgid[symbol] = msgid existing_old_names = self.__old_names.get(msgid, []) existing_old_names.append(new_msgid) self.__old_names[msgid] = existing_old_names def check_msgid_and_symbol(self, msgid: str, symbol: str) -> None: existing_msgid: Optional[str] = self.__symbol_to_msgid.get(symbol) existing_symbol: Optional[str] = self.__msgid_to_symbol.get(msgid) if existing_symbol is None and existing_msgid is None: return # both symbol and msgid are usable if existing_msgid is not None: if existing_msgid != msgid: self._raise_duplicate_msgid(symbol, msgid, existing_msgid) if existing_symbol and existing_symbol != symbol: # See https://github.com/python/mypy/issues/10559 self._raise_duplicate_symbol(msgid, symbol, existing_symbol) @staticmethod def _raise_duplicate_symbol(msgid: str, symbol: str, other_symbol: str) -> NoReturn: """Raise an error when a symbol is duplicated.""" symbols = [symbol, other_symbol] symbols.sort() error_message = f"Message id '{msgid}' cannot have both " error_message += f"'{symbols[0]}' and '{symbols[1]}' as symbolic name." raise InvalidMessageError(error_message) @staticmethod def _raise_duplicate_msgid(symbol: str, msgid: str, other_msgid: str) -> NoReturn: """Raise an error when a msgid is duplicated.""" msgids = [msgid, other_msgid] msgids.sort() error_message = ( f"Message symbol '{symbol}' cannot be used for " f"'{msgids[0]}' and '{msgids[1]}' at the same time." f" If you're creating an 'old_names' use 'old-{symbol}' as the old symbol." ) raise InvalidMessageError(error_message) def get_active_msgids(self, msgid_or_symbol: str) -> List[str]: """Return msgids but the input can be a symbol. self.__active_msgids is used to implement a primitive cache for this function. """ try: return self.__active_msgids[msgid_or_symbol] except KeyError: pass # If we don't have a cached value yet we compute it msgid: Optional[str] if msgid_or_symbol[1:].isdigit(): # Only msgid can have a digit as second letter msgid = msgid_or_symbol.upper() symbol = self.__msgid_to_symbol.get(msgid) else: msgid = self.__symbol_to_msgid.get(msgid_or_symbol) symbol = msgid_or_symbol if not msgid or not symbol: error_msg = f"No such message id or symbol '{msgid_or_symbol}'." raise UnknownMessageError(error_msg) ids = self.__old_names.get(msgid, [msgid]) # Add to cache self.__active_msgids[msgid_or_symbol] = ids return ids
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/message/message_id_store.py
pylint/message/message_id_store.py
73
check_msgid_and_symbol
def
function
def check_msgid_and_symbol(self, msgid: str, symbol: str) -> None: existing_msgid: Optional[str] = self.__symbol_to_msgid.get(symbol) existing_symbol: Optional[str] = self.__msgid_to_symbol.get(msgid) if existing_symbol is None and existing_msgid is None: return # both symbol and msgid are usable if existing_msgid is not None: if existing_msgid != msgid: self._raise_duplicate_msgid(symbol, msgid, existing_msgid) if existing_symbol and existing_symbol != symbol: # See https://github.com/python/mypy/issues/10559 self._raise_duplicate_symbol(msgid, symbol, existing_symbol) @staticmethod def _raise_duplicate_symbol(msgid: str, symbol: str, other_symbol: str) -> NoReturn: """Raise an error when a symbol is duplicated.""" symbols = [symbol, other_symbol] symbols.sort() error_message = f"Message id '{msgid}' cannot have both " error_message += f"'{symbols[0]}' and '{symbols[1]}' as symbolic name." raise InvalidMessageError(error_message) @staticmethod def _raise_duplicate_msgid(symbol: str, msgid: str, other_msgid: str) -> NoReturn: """Raise an error when a msgid is duplicated.""" msgids = [msgid, other_msgid] msgids.sort() error_message = ( f"Message symbol '{symbol}' cannot be used for " f"'{msgids[0]}' and '{msgids[1]}' at the same time." f" If you're creating an 'old_names' use 'old-{symbol}' as the old symbol." ) raise InvalidMessageError(error_message) def get_active_msgids(self, msgid_or_symbol: str) -> List[str]: """Return msgids but the input can be a symbol. self.__active_msgids is used to implement a primitive cache for this function. """ try: return self.__active_msgids[msgid_or_symbol] except KeyError: pass # If we don't have a cached value yet we compute it msgid: Optional[str] if msgid_or_symbol[1:].isdigit(): # Only msgid can have a digit as second letter msgid = msgid_or_symbol.upper() symbol = self.__msgid_to_symbol.get(msgid) else: msgid = self.__symbol_to_msgid.get(msgid_or_symbol) symbol = msgid_or_symbol if not msgid or not symbol: error_msg = f"No such message id or symbol '{msgid_or_symbol}'." raise UnknownMessageError(error_msg) ids = self.__old_names.get(msgid, [msgid]) # Add to cache self.__active_msgids[msgid_or_symbol] = ids return ids
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/message/message_id_store.py
pylint/message/message_id_store.py
80
_raise_duplicate_msgid
ref
function
self._raise_duplicate_msgid(symbol, msgid, existing_msgid)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/message/message_id_store.py
pylint/message/message_id_store.py
83
_raise_duplicate_symbol
ref
function
self._raise_duplicate_symbol(msgid, symbol, existing_symbol)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/message/message_id_store.py
pylint/message/message_id_store.py
86
_raise_duplicate_symbol
def
function
def _raise_duplicate_symbol(msgid: str, symbol: str, other_symbol: str) -> NoReturn: """Raise an error when a symbol is duplicated.""" symbols = [symbol, other_symbol] symbols.sort() error_message = f"Message id '{msgid}' cannot have both " error_message += f"'{symbols[0]}' and '{symbols[1]}' as symbolic name." raise InvalidMessageError(error_message) @staticmethod def _raise_duplicate_msgid(symbol: str, msgid: str, other_msgid: str) -> NoReturn: """Raise an error when a msgid is duplicated.""" msgids = [msgid, other_msgid] msgids.sort() error_message = ( f"Message symbol '{symbol}' cannot be used for " f"'{msgids[0]}' and '{msgids[1]}' at the same time." f" If you're creating an 'old_names' use 'old-{symbol}' as the old symbol." ) raise InvalidMessageError(error_message) def get_active_msgids(self, msgid_or_symbol: str) -> List[str]: """Return msgids but the input can be a symbol. self.__active_msgids is used to implement a primitive cache for this function. """ try: return self.__active_msgids[msgid_or_symbol] except KeyError: pass # If we don't have a cached value yet we compute it msgid: Optional[str] if msgid_or_symbol[1:].isdigit(): # Only msgid can have a digit as second letter msgid = msgid_or_symbol.upper() symbol = self.__msgid_to_symbol.get(msgid) else: msgid = self.__symbol_to_msgid.get(msgid_or_symbol) symbol = msgid_or_symbol if not msgid or not symbol: error_msg = f"No such message id or symbol '{msgid_or_symbol}'." raise UnknownMessageError(error_msg) ids = self.__old_names.get(msgid, [msgid]) # Add to cache self.__active_msgids[msgid_or_symbol] = ids return ids
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/message/message_id_store.py
pylint/message/message_id_store.py
92
InvalidMessageError
ref
function
raise InvalidMessageError(error_message)
playground/e9b22a58-260b-483f-88d7-7a5fe9f8b1d4/pylint/pylint/message/message_id_store.py
pylint/message/message_id_store.py
95
_raise_duplicate_msgid
def
function
def _raise_duplicate_msgid(symbol: str, msgid: str, other_msgid: str) -> NoReturn: """Raise an error when a msgid is duplicated.""" msgids = [msgid, other_msgid] msgids.sort() error_message = ( f"Message symbol '{symbol}' cannot be used for " f"'{msgids[0]}' and '{msgids[1]}' at the same time." f" If you're creating an 'old_names' use 'old-{symbol}' as the old symbol." ) raise InvalidMessageError(error_message) def get_active_msgids(self, msgid_or_symbol: str) -> List[str]: """Return msgids but the input can be a symbol. self.__active_msgids is used to implement a primitive cache for this function. """ try: return self.__active_msgids[msgid_or_symbol] except KeyError: pass # If we don't have a cached value yet we compute it msgid: Optional[str] if msgid_or_symbol[1:].isdigit(): # Only msgid can have a digit as second letter msgid = msgid_or_symbol.upper() symbol = self.__msgid_to_symbol.get(msgid) else: msgid = self.__symbol_to_msgid.get(msgid_or_symbol) symbol = msgid_or_symbol if not msgid or not symbol: error_msg = f"No such message id or symbol '{msgid_or_symbol}'." raise UnknownMessageError(error_msg) ids = self.__old_names.get(msgid, [msgid]) # Add to cache self.__active_msgids[msgid_or_symbol] = ids return ids