Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make banned-api config setting optional #1465

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions ruff.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1095,9 +1095,6 @@
},
"Flake8TidyImportsOptions": {
"type": "object",
"required": [
"banned-api"
],
"properties": {
"ban-relative-imports": {
"description": "Whether to ban all relative imports (`\"all\"`), or only those imports that extend into the parent module or beyond (`\"parents\"`).",
Expand All @@ -1112,7 +1109,10 @@
},
"banned-api": {
"description": "Specific modules or module members that may not be imported or accessed. Note that this check is only meant to flag accidental uses, and can be circumvented via `eval` or `importlib`.",
"type": "object",
"type": [
"object",
"null"
],
"additionalProperties": {
"$ref": "#/definitions/BannedApi"
}
Expand Down
6 changes: 3 additions & 3 deletions src/flake8_tidy_imports/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub struct Options {
/// Specific modules or module members that may not be imported or accessed.
/// Note that this check is only meant to flag accidental uses,
/// and can be circumvented via `eval` or `importlib`.
pub banned_api: FxHashMap<String, BannedApi>,
pub banned_api: Option<FxHashMap<String, BannedApi>>,
}

#[derive(Debug)]
Expand All @@ -78,7 +78,7 @@ impl From<Options> for Settings {
fn from(options: Options) -> Self {
Self {
ban_relative_imports: options.ban_relative_imports.unwrap_or(Strictness::Parents),
banned_api: options.banned_api,
banned_api: options.banned_api.unwrap_or_default(),
}
}
}
Expand All @@ -87,7 +87,7 @@ impl From<Settings> for Options {
fn from(settings: Settings) -> Self {
Self {
ban_relative_imports: Some(settings.ban_relative_imports),
banned_api: settings.banned_api,
banned_api: Some(settings.banned_api),
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/settings/pyproject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ other-attribute = 1
}),
flake8_tidy_imports: Some(flake8_tidy_imports::settings::Options {
ban_relative_imports: Some(Strictness::Parents),
banned_api: FxHashMap::from_iter([
banned_api: Some(FxHashMap::from_iter([
(
"cgi".to_string(),
BannedApi {
Expand All @@ -528,7 +528,7 @@ other-attribute = 1
msg: "Use typing_extensions.TypedDict instead.".to_string()
}
)
])
]))
}),
flake8_import_conventions: Some(flake8_import_conventions::settings::Options {
aliases: Some(FxHashMap::from_iter([(
Expand Down