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

Avoid multiple assignments of constant ALLOWED_INPUT_SCHEMAS #280

Merged
merged 1 commit into from
Feb 3, 2025
Merged
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
9 changes: 5 additions & 4 deletions dandischema/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@
"0.6.6",
"0.6.7",
"0.6.8",
DANDI_SCHEMA_VERSION,
]

# ATM we allow only for a single target version which is current
# migrate has a guard now for this since it cannot migrate to anything but current
# version
ALLOWED_TARGET_SCHEMAS = [DANDI_SCHEMA_VERSION]

# This allows multiple schemas for validation, whereas target schemas focus on
# migration.
ALLOWED_VALIDATION_SCHEMAS = ALLOWED_TARGET_SCHEMAS + ALLOWED_INPUT_SCHEMAS

if DANDI_SCHEMA_VERSION not in ALLOWED_INPUT_SCHEMAS:
ALLOWED_INPUT_SCHEMAS.append(DANDI_SCHEMA_VERSION)
ALLOWED_VALIDATION_SCHEMAS = sorted(
set(ALLOWED_INPUT_SCHEMAS).union(ALLOWED_TARGET_SCHEMAS)
)
Comment on lines +25 to +27
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If set(ALLOWED_TARGET_SCHEMAS) is always a subset of set(ALLOWED_INPUT_SCHEMAS), as it currently is, we can further simplify the definition of ALLOWED_VALIDATION_SCHEMAS to the following.

Suggested change
ALLOWED_VALIDATION_SCHEMAS = sorted(
set(ALLOWED_INPUT_SCHEMAS).union(ALLOWED_TARGET_SCHEMAS)
)
ALLOWED_VALIDATION_SCHEMAS = ALLOWED_INPUT_SCHEMAS

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

feels like indeed we could have simplified like this, but for now let's just keep as is, may be there would be some time some divergence ;-)

Loading