Skip to content

Commit

Permalink
Add a new flag to disable PEP 740 support. (pypi#16645)
Browse files Browse the repository at this point in the history
* Add a new flag to disable PEP 740 support.

* fixup migration

Signed-off-by: William Woodruff <william@trailofbits.com>

* migrations: flip PEP740 flag default

PEP 740 should be enabled by default.

Signed-off-by: William Woodruff <william@trailofbits.com>

* Apply suggestions from code review

Co-authored-by: Dustin Ingram <di@users.noreply.github.com>

* migrations: rebase DISABLE_PEP740 flag migration

Signed-off-by: William Woodruff <william@trailofbits.com>

---------

Signed-off-by: William Woodruff <william@trailofbits.com>
Co-authored-by: William Woodruff <william@trailofbits.com>
Co-authored-by: William Woodruff <william@yossarian.net>
Co-authored-by: Dustin Ingram <di@users.noreply.github.com>
  • Loading branch information
4 people authored Sep 13, 2024
1 parent 80144c2 commit 738267a
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
1 change: 1 addition & 0 deletions warehouse/admin/flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

class AdminFlagValue(enum.Enum):
DISABLE_ORGANIZATIONS = "disable-organizations"
DISABLE_PEP740 = "disable-pep740"
DISALLOW_DELETION = "disallow-deletion"
DISALLOW_NEW_PROJECT_REGISTRATION = "disallow-new-project-registration"
DISALLOW_NEW_UPLOAD = "disallow-new-upload"
Expand Down
4 changes: 3 additions & 1 deletion warehouse/forklift/legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -1251,7 +1251,9 @@ def file_upload(request):
k: h.hexdigest().lower() for k, h in metadata_file_hashes.items()
}

if "attestations" in request.POST:
if "attestations" in request.POST and not request.flags.enabled(
AdminFlagValue.DISABLE_PEP740
):
_process_attestations(
request=request,
distribution=Distribution(name=filename, digest=file_hashes["sha256"]),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""
add DISABLE_PEP740 flag
Revision ID: 2e049cda494f
Revises: f204918656f1
Create Date: 2024-09-05 15:15:58.703955
"""

from alembic import op

revision = "2e049cda494f"
down_revision = "f204918656f1"


def upgrade():
op.execute(
"""
INSERT INTO admin_flags(id, description, enabled, notify)
VALUES (
'disable-pep740',
'Disable PEP 740 support.',
FALSE,
FALSE
)
"""
)


def downgrade():
op.execute("DELETE FROM admin_flags WHERE id = 'disable-pep740'")

0 comments on commit 738267a

Please sign in to comment.