add updates libs

This commit is contained in:
Christoph Brandau
2026-06-18 17:21:58 +02:00
parent 91ce762570
commit 41f331d4c4
150 changed files with 8249 additions and 2550 deletions
+39 -43
View File
@@ -3,21 +3,16 @@
import argparse
import pathlib
import sys
from typing import Dict, List, Optional
from typing import Optional
from tclint.config import (
get_config,
setup_config_cli_args,
Config,
ConfigError,
RunConfig,
)
from tclint.parser import Parser, TclSyntaxError
from tclint.checks import get_checkers
from tclint.violations import Violation, Rule
from tclint.cli.resolver import Resolver
from tclint.cli.utils import register_codec_warning
from tclint.commands.plugins import PluginManager
from tclint.comments import CommentVisitor
from tclint.cli.utils import resolve_sources, register_codec_warning
from tclint.config import Config, ConfigError, setup_config_cli_args
from tclint.parser import Parser, TclSyntaxError
from tclint.violations import Rule, Violation
try:
from tclint._version import __version__ # type: ignore
@@ -32,10 +27,10 @@ EXIT_INPUT_ERROR = 4
def filter_violations(
violations: List[Violation],
config_ignore: List[Rule],
inline_ignore: Dict[int, List[Rule]],
) -> List[Violation]:
violations: list[Violation],
config_ignore: list[Rule],
inline_ignore: dict[int, list[Rule]],
) -> list[Violation]:
filtered_violations = []
for violation in violations:
@@ -53,11 +48,11 @@ def filter_violations(
def lint(
script: str,
config: Config,
plugins: PluginManager,
path: Optional[pathlib.Path],
debug=0,
) -> List[Violation]:
plugins = [config.commands] if config.commands is not None else []
parser = Parser(debug=(debug > 0), command_plugins=plugins)
) -> list[Violation]:
parser = Parser(debug=(debug > 0), commands=plugins.get_commands(config.commands))
violations = []
tree = parser.parse(script)
@@ -66,7 +61,7 @@ def lint(
if debug > 0:
print(tree.pretty(positions=(debug > 1)))
for checker in get_checkers():
for checker in get_checkers(plugins):
violations += checker.check(script, tree, config)
v = CommentVisitor()
@@ -105,40 +100,40 @@ def main():
default=None,
metavar="<path>",
)
setup_config_cli_args(parser)
cwd = pathlib.Path.cwd()
setup_config_cli_args(parser, cwd)
args = parser.parse_args()
global_config = None
if args.config is not None:
try:
global_config = Config.from_path(args.config, cwd)
global_config.apply_cli_args(args)
except FileNotFoundError:
print(f"Config file path doesn't exist: {args.config}")
return EXIT_INPUT_ERROR
except ConfigError as e:
print(f"Invalid config file: {e}")
return EXIT_INPUT_ERROR
resolver = Resolver(args, global_config)
try:
config = get_config(args.config, pathlib.Path())
sources = resolver.resolve_sources(args.source, cwd)
except FileNotFoundError as e:
print(f"Invalid path provided: {e}")
return EXIT_INPUT_ERROR
except ConfigError as e:
print(f"Invalid config file: {e}")
return EXIT_INPUT_ERROR
if config is None:
config = RunConfig()
config.apply_cli_args(args)
try:
# TODO: we should eventually allow tclint to find a config by walking up
# directories, at which point exclude_root should be the parent dir of
# the config file, unless -c is used (eslint rules)
exclude_root = pathlib.Path.cwd()
sources = resolve_sources(
args.source,
exclude_patterns=config.exclude,
exclude_root=exclude_root,
extensions=config.extensions,
)
except FileNotFoundError as e:
print(f"Invalid path provided: {e}")
return EXIT_INPUT_ERROR
plugin_manager = PluginManager(trust_uninstalled=args.trust_plugins)
retcode = EXIT_OK
register_codec_warning("replace_with_warning")
for path in sources:
for path, config in sources:
if path is None:
script = sys.stdin.read()
out_prefix = "(stdin)"
@@ -150,7 +145,8 @@ def main():
try:
violations = lint(
script,
config.get_for_path(path),
config,
plugin_manager,
path,
debug=args.debug,
)