From 1b082ce67e56661f75b64d566a5b39025681fd86 Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Fri, 15 Sep 2023 13:10:06 -0500 Subject: [PATCH] Add maximum length for `line-length` to JSON schema (#7412) ## Summary Adds the maximum of 320 for the line-length setting to the JSON schema for better integration with IDEs. Related https://github.com/astral-sh/ruff/pull/6873 ## Test Plan --- crates/ruff_workspace/src/options.rs | 3 ++- ruff.schema.json | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/crates/ruff_workspace/src/options.rs b/crates/ruff_workspace/src/options.rs index 3c8cc9e227494..6c085308cbd46 100644 --- a/crates/ruff_workspace/src/options.rs +++ b/crates/ruff_workspace/src/options.rs @@ -319,7 +319,8 @@ pub struct Options { "# )] /// The line length to use when enforcing long-lines violations (like - /// `E501`). Must be greater than `0`. + /// `E501`). Must be greater than `0` and less than or equal to `320`. + #[cfg_attr(feature = "schemars", schemars(range(min = 1, max = 320)))] pub line_length: Option, #[option( default = "4", diff --git a/ruff.schema.json b/ruff.schema.json index 9984598eaa4a7..05b0216013795 100644 --- a/ruff.schema.json +++ b/ruff.schema.json @@ -376,7 +376,7 @@ ] }, "line-length": { - "description": "The line length to use when enforcing long-lines violations (like `E501`). Must be greater than `0`.", + "description": "The line length to use when enforcing long-lines violations (like `E501`). Must be greater than `0` and less than or equal to `320`.", "anyOf": [ { "$ref": "#/definitions/LineLength" @@ -384,7 +384,9 @@ { "type": "null" } - ] + ], + "maximum": 320.0, + "minimum": 1.0 }, "logger-objects": { "description": "A list of objects that should be treated equivalently to a `logging.Logger` object.\n\nThis is useful for ensuring proper diagnostics (e.g., to identify `logging` deprecations and other best-practices) for projects that re-export a `logging.Logger` object from a common module.\n\nFor example, if you have a module `logging_setup.py` with the following contents: ```python import logging\n\nlogger = logging.getLogger(__name__) ```\n\nAdding `\"logging_setup.logger\"` to `logger-objects` will ensure that `logging_setup.logger` is treated as a `logging.Logger` object when imported from other modules (e.g., `from logging_setup import logger`).",