forked from phoenix-oss/llama-stack-mirror
fix: enforce stricter ASCII rules lint rules in Ruff (#2062)
# What does this PR do? - Added new Ruff lint rules to detect ambiguous or non-ASCII characters: - Added per-file ignores where Unicode usage is still required. - Fixed whatever had to be fixed Signed-off-by: Sébastien Han <seb@redhat.com>
This commit is contained in:
parent
eab550f7d2
commit
2c7aba4158
3 changed files with 29 additions and 12 deletions
|
@ -119,7 +119,7 @@ class StackRun(Subcommand):
|
|||
|
||||
if not config_file.is_file():
|
||||
self.parser.error(
|
||||
f"Config file must be a valid file path, '{config_file}’ is not a file: type={type(config_file)}"
|
||||
f"Config file must be a valid file path, '{config_file}' is not a file: type={type(config_file)}"
|
||||
)
|
||||
|
||||
logger.info(f"Using run configuration: {config_file}")
|
||||
|
|
|
@ -47,14 +47,13 @@ def get_provider_dependencies(
|
|||
providers = config.distribution_spec.providers
|
||||
deps = []
|
||||
registry = get_provider_registry(config)
|
||||
|
||||
for api_str, provider_or_providers in providers.items():
|
||||
providers_for_api = registry[Api(api_str)]
|
||||
|
||||
providers = provider_or_providers if isinstance(provider_or_providers, list) else [provider_or_providers]
|
||||
|
||||
for provider in providers:
|
||||
# Providers from BuildConfig and RunConfig are subtly different – not great
|
||||
# Providers from BuildConfig and RunConfig are subtly different - not great
|
||||
provider_type = provider if isinstance(provider, str) else provider.provider_type
|
||||
|
||||
if provider_type not in providers_for_api:
|
||||
|
|
|
@ -153,6 +153,16 @@ select = [
|
|||
"W", # Warnings
|
||||
"DTZ", # datetime rules
|
||||
"I", # isort (imports order)
|
||||
"RUF001", # Checks for ambiguous Unicode characters in strings
|
||||
"RUF002", # Checks for ambiguous Unicode characters in docstrings
|
||||
"RUF003", # Checks for ambiguous Unicode characters in comments
|
||||
"PLC2401", # Checks for the use of non-ASCII characters in variable names
|
||||
"PLC2403", # Checks for the use of non-ASCII characters in import statements
|
||||
"PLE2510", # Checks for strings that contain the control character BS.
|
||||
"PLE2512", # Checks for strings that contain the raw control character SUB.
|
||||
"PLE2513", # Checks for strings that contain the raw control character ESC.
|
||||
"PLE2514", # Checks for strings that contain the raw control character NUL (0 byte).
|
||||
"PLE2515", # Checks for strings that contain the zero width space character.
|
||||
]
|
||||
ignore = [
|
||||
# The following ignores are desired by the project maintainers.
|
||||
|
@ -165,10 +175,18 @@ ignore = [
|
|||
# These are the additional ones we started ignoring after moving to ruff. We should look into each one of them later.
|
||||
"C901", # Complexity of the function is too high
|
||||
]
|
||||
unfixable = [
|
||||
"PLE2515",
|
||||
] # Do not fix this automatically since ruff will replace the zero-width space with \u200b - let's do it manually
|
||||
|
||||
# Ignore the following errors for the following files
|
||||
[tool.ruff.lint.per-file-ignores]
|
||||
"tests/**/*.py" = ["DTZ"] # Ignore datetime rules for tests
|
||||
"llama_stack/providers/inline/scoring/basic/utils/ifeval_utils.py" = ["RUF001"]
|
||||
"llama_stack/providers/inline/scoring/basic/scoring_fn/fn_defs/regex_parser_multiple_choice_answer.py" = [
|
||||
"RUF001",
|
||||
"PLE2515",
|
||||
]
|
||||
|
||||
[tool.mypy]
|
||||
mypy_path = ["llama_stack"]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue