From 1fbb4ac752e68b5840b9e09b68e44a165569bfa6 Mon Sep 17 00:00:00 2001 From: Donald Stufft Date: Wed, 28 Nov 2018 13:51:19 -0500 Subject: [PATCH] Add isort as a companion to black (#5132) --- Makefile | 2 ++ requirements/lint.in | 1 + requirements/lint.txt | 4 ++++ setup.cfg | 11 ++++++++++ tests/common/db/accounts.py | 4 ++-- tests/common/db/ses.py | 2 +- tests/conftest.py | 6 +++--- tests/functional/test_templates.py | 4 +++- tests/unit/accounts/test_auth_policy.py | 3 ++- tests/unit/accounts/test_core.py | 10 ++++----- tests/unit/accounts/test_models.py | 2 +- tests/unit/accounts/test_services.py | 6 +++--- tests/unit/accounts/test_views.py | 4 ++-- tests/unit/admin/test_core.py | 2 +- tests/unit/admin/views/test_blacklist.py | 4 ++-- tests/unit/admin/views/test_emails.py | 4 ++-- tests/unit/admin/views/test_projects.py | 2 +- tests/unit/admin/views/test_users.py | 5 +++-- tests/unit/email/ses/test_models.py | 2 +- tests/unit/email/ses/test_tasks.py | 2 +- tests/unit/email/test_services.py | 2 +- tests/unit/forklift/test_legacy.py | 14 ++++++------- tests/unit/i18n/test_filters.py | 3 ++- tests/unit/legacy/api/test_json.py | 4 ++-- tests/unit/legacy/api/test_simple.py | 4 ++-- tests/unit/legacy/api/xmlrpc/test_cache.py | 7 ++++--- tests/unit/legacy/api/xmlrpc/test_xmlrpc.py | 4 ++-- tests/unit/manage/test_views.py | 6 +++--- tests/unit/metrics/test_event_handlers.py | 8 +++---- tests/unit/metrics/test_init.py | 4 ++-- tests/unit/metrics/test_services.py | 4 ++-- tests/unit/metrics/test_views.py | 2 +- tests/unit/packaging/test_init.py | 2 +- tests/unit/packaging/test_models.py | 4 ++-- tests/unit/packaging/test_search.py | 1 + tests/unit/packaging/test_services.py | 6 +++--- tests/unit/packaging/test_views.py | 2 +- tests/unit/rate_limiting/test_core.py | 4 ++-- tests/unit/rss/test_views.py | 1 + tests/unit/search/test_tasks.py | 6 +++--- tests/unit/sitemap/test_views.py | 1 + tests/unit/test_config.py | 2 +- tests/unit/test_db.py | 2 +- tests/unit/test_forms.py | 2 +- tests/unit/test_http.py | 2 +- tests/unit/test_raven.py | 3 ++- tests/unit/test_redirects.py | 2 +- tests/unit/test_sanity.py | 2 +- tests/unit/test_sessions.py | 2 +- tests/unit/test_tasks.py | 1 - tests/unit/test_views.py | 15 +++++++------ tests/unit/utils/test_compression.py | 8 ++++--- tests/unit/utils/test_project.py | 11 +++++----- tests/unit/utils/test_sns.py | 7 +++---- warehouse/__main__.py | 1 - warehouse/accounts/forms.py | 2 +- warehouse/accounts/models.py | 12 ++++++----- warehouse/accounts/services.py | 7 +++---- warehouse/accounts/views.py | 11 +++++----- warehouse/admin/flags.py | 2 +- warehouse/admin/squats.py | 3 +-- warehouse/admin/views/blacklist.py | 4 ++-- warehouse/admin/views/projects.py | 7 +++---- warehouse/admin/views/users.py | 4 ++-- warehouse/cache/http.py | 1 - warehouse/cli/db/branches.py | 2 +- warehouse/cli/db/current.py | 2 +- warehouse/cli/db/downgrade.py | 2 +- warehouse/cli/db/heads.py | 2 +- warehouse/cli/db/history.py | 2 +- warehouse/cli/db/merge.py | 2 +- warehouse/cli/db/revision.py | 2 +- warehouse/cli/db/show.py | 2 +- warehouse/cli/db/stamp.py | 2 +- warehouse/cli/db/upgrade.py | 2 +- warehouse/config.py | 2 +- warehouse/csp.py | 1 - warehouse/csrf.py | 1 - warehouse/db.py | 1 - warehouse/email/ses/models.py | 4 +--- warehouse/email/ses/tasks.py | 1 - warehouse/filters.py | 1 - warehouse/forklift/legacy.py | 14 ++++++------- warehouse/http.py | 1 + warehouse/i18n/filters.py | 3 ++- warehouse/legacy/api/json.py | 3 +-- warehouse/legacy/api/simple.py | 2 +- warehouse/legacy/api/xmlrpc/cache/fncache.py | 1 + warehouse/legacy/api/xmlrpc/views.py | 6 +++--- warehouse/manage/views.py | 6 +++--- ...e2dbf9_record_when_the_password_was_set.py | 2 +- .../versions/06bfbc92f67d_rename_tables.py | 1 - .../versions/08447ab49999_optimize_queries.py | 1 - .../0864352e2168_drop_duplicate_indexes.py | 1 - ...0977b97fce94_add_file_blake2_256_digest.py | 1 - ...c56862b_denormalize_serial_onto_project.py | 2 +- ...aea73_default_hosting_mode_to_pypi_only.py | 1 - .../111d8fc0443_use_enums_instead_of_text.py | 1 - ...7e1_add_a_sitemap_bucket_column_to_user.py | 2 +- .../128a0ead322_add_primary_key_roles.py | 3 ++- ...e_create_openid_connect_sub_column_for_.py | 2 +- ..._readd_the_unique_constraint_on_pep426_.py | 1 - ...ove_existing_blacklisted_projects_into_.py | 1 - ...1f002cab0a7_add_size_signature_and_docs.py | 2 +- ...3_data_migration_for_canonical_version_.py | 4 ++-- .../23a3c4ffe5d_relax_normalization_rules.py | 1 - ...30e54f8717_reset_classifier_id_sequence.py | 1 - .../versions/283c68f2ab2_initial_migration.py | 3 +-- ...drop_denormalized_normalized_name_field.py | 1 - ...79e_cascade_project_deletion_to_release.py | 1 - .../versions/2d6390eebe90_fix_typo.py | 1 - .../312040efcfe_default_upload_time_to_now.py | 2 +- ...06ba_normalize_runs_of_characters_to_a_.py | 1 - ...880_add_a_table_to_maintain_a_count_of_.py | 3 ++- ...219a_add_a_flag_for_legacy_file_support.py | 2 +- ...1abd35caa3_add_index_on_release_created.py | 2 +- ...fbe5_remove_the_description_html_column.py | 1 - ...add_a_server_default_for_submitted_date.py | 3 ++- ...c_add_a_column_for_tracking_why_a_user_.py | 2 +- ...dd_function_to_convert_string_to_bucket.py | 1 - ...7b73_drop_indexes_that_are_a_subset_of_.py | 1 - ..._add_a_sitemap_bucket_column_to_project.py | 2 +- ...9dd_move_all_user_fks_to_id_instead_of_.py | 3 +-- .../56e9e630c748_add_fuzzystrmatch.py | 1 - ...3e8d2e_add_primary_key_to_release_files.py | 3 ++- ..._add_a_column_to_project_to_record_the_.py | 2 +- ...3989_add_description_content_type_field.py | 2 +- ...ff0c99c94_add_primary_key_to_dependency.py | 3 ++- ...6becc7653_set_user_is_staff_to_nullable.py | 1 - .../6418f7d86a4b_add_read_only_adminflag.py | 1 - ...add_a_column_to_track_if_the_email_was_.py | 2 +- ...a5_add_missing_indexes_for_foreign_keys.py | 1 - ...d_add_a_function_to_get_the_array_index.py | 1 - .../6a6eb0a95603_drop_unused_indexes.py | 1 - ...dd_a_path_column_to_store_the_location_.py | 2 +- ...165e957cddc_create_table_for_warehouse_.py | 2 +- .../7750037b351a_remove_useless_index.py | 1 - ..._add_tables_for_storing_ses_information.py | 3 ++- ...79cc4490_cascade_deletes_for_ses_events.py | 1 - ...switch_to_a_uuid_based_primary_key_for_.py | 1 - .../91508cc5c2_add_pep_426_normalize_index.py | 1 - ...3533_add_a_column_to_specify_a_project_.py | 2 +- ...91f0fe9c2_update_release_file_on_insert.py | 1 - ...f_set_user_last_login_automatically_in_.py | 2 +- ...3b3efd8_uploaded_via_field_for_release_.py | 2 +- ...dd_a_table_to_hold_blacklisted_projects.py | 4 ++-- ...2_add_ondelete_cascade_for_description_.py | 1 - ...bb5_updated_to_newer_alembic_mechanisms.py | 1 - ...57_add_requires_python_to_release_files.py | 2 +- ...e785eed9_add_notify_column_to_adminflag.py | 3 ++- .../c0682028c857_cascade_role_deletion.py | 1 - ...a1bf519_add_a_column_for_sha256_digests.py | 1 - ...0b_add_deprecated_column_to_classifiers.py | 2 +- ...2a92c1017_add_uploader_field_to_release.py | 3 +-- .../e7b09b5c089d_add_pep440_is_prerelease.py | 1 - .../e82c3a017d60_remove_unused_columns.py | 1 - ...6a223_migrate_projects_and_releases_to_.py | 3 ++- .../versions/eeb23d9b4d00_add_squats_table.py | 2 +- ...53c96ded_remove_no_longer_needed_tables.py | 1 - ...a1b_mandate_sha256_hashes_for_all_files.py | 1 - ...370_disable_legacy_file_types_unless_a_.py | 1 - ..._disallow_multiple_sdists_for_a_release.py | 2 +- .../f46672a776f1_make_file_path_mandatory.py | 1 - ...577b6938c1_add_canonical_version_column.py | 2 +- ...ensure_file_md5_blake2_256__digest_are_.py | 1 - warehouse/packaging/models.py | 14 +++++++------ warehouse/packaging/search.py | 3 +-- warehouse/packaging/services.py | 2 +- warehouse/packaging/views.py | 2 +- warehouse/policy.py | 1 - warehouse/redirects.py | 2 +- warehouse/sanity.py | 2 +- warehouse/search/tasks.py | 11 +++++----- warehouse/sitemap/views.py | 3 +-- warehouse/static.py | 1 - warehouse/tasks.py | 15 +++++++------ warehouse/utils/compression.py | 1 - warehouse/utils/crypto.py | 1 - warehouse/utils/http.py | 2 +- warehouse/utils/project.py | 2 +- warehouse/utils/readme.py | 1 - warehouse/utils/row_counter.py | 3 +-- warehouse/utils/sns.py | 1 - warehouse/views.py | 21 +++++++++---------- 184 files changed, 269 insertions(+), 294 deletions(-) diff --git a/Makefile b/Makefile index beb526e09121..e7c3a7d87a94 100644 --- a/Makefile +++ b/Makefile @@ -102,11 +102,13 @@ tests: reformat: .state/env/pyvenv.cfg + $(BINDIR)/isort -rc warehouse/ tests/ $(BINDIR)/black warehouse/ tests/ lint: .state/env/pyvenv.cfg $(BINDIR)/flake8 . $(BINDIR)/black --check warehouse/ tests/ + $(BINDIR)/isort -rc -c warehouse/ tests/ $(BINDIR)/doc8 --allow-long-titles README.rst CONTRIBUTING.rst docs/ --ignore-path docs/_build/ # TODO: Figure out a solution to https://github.com/deezer/template-remover/issues/1 # so we can remove extra_whitespace from below. diff --git a/requirements/lint.in b/requirements/lint.in index 8aa917274c05..883862d2f5aa 100644 --- a/requirements/lint.in +++ b/requirements/lint.in @@ -3,3 +3,4 @@ flake8 html-linter pep8-naming black==18.9b0 +isort diff --git a/requirements/lint.txt b/requirements/lint.txt index d1c2d3e870ee..e2d2d4bd0548 100644 --- a/requirements/lint.txt +++ b/requirements/lint.txt @@ -30,6 +30,10 @@ flake8==3.6.0 \ --hash=sha256:c01f8a3963b3571a8e6bd7a4063359aff90749e160778e03817cd9b71c9e07d2 html-linter==0.4.0 \ --hash=sha256:342dad677f2fc810a2562fde0959046ed0d8fa1387bd9e085869e908c1941191 +isort==4.3.4 \ + --hash=sha256:1153601da39a25b14ddc54955dbbacbb6b2d19135386699e2ad58517953b34af \ + --hash=sha256:b9c40e9750f3d77e6e4d441d8b0266cf555e7cdabdcff33c4fd06366ca761ef8 \ + --hash=sha256:ec9ef8f4a9bc6f71eec99e1806bfa2de401650d996c59330782b89a5555c1497 mccabe==0.6.1 \ --hash=sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42 \ --hash=sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f diff --git a/setup.cfg b/setup.cfg index 889fe9ec1879..b5e3320f3545 100644 --- a/setup.cfg +++ b/setup.cfg @@ -4,6 +4,17 @@ exclude = *.egg,*/interfaces.py,node_modules,.state ignore = W503,E203 select = E,W,F,N +[isort] +multi_line_output=3 +include_trailing_comma=True +force_grid_wrap=0 +use_parentheses=True +line_length=88 +lines_between_types=1 +combine_as_imports=True +default_section=THIRDPARTY +known_first_party=warehouse,tests + [tool:pytest] norecursedirs = build dist node_modules *.egg-info .state requirements markers = diff --git a/tests/common/db/accounts.py b/tests/common/db/accounts.py index 113b86b51f4a..39449ea9c62c 100644 --- a/tests/common/db/accounts.py +++ b/tests/common/db/accounts.py @@ -15,9 +15,9 @@ import factory import factory.fuzzy -from warehouse.accounts.models import User, Email +from warehouse.accounts.models import Email, User -from .base import WarehouseFactory, FuzzyEmail +from .base import FuzzyEmail, WarehouseFactory class UserFactory(WarehouseFactory): diff --git a/tests/common/db/ses.py b/tests/common/db/ses.py index 415b98f6ace8..3442c474a941 100644 --- a/tests/common/db/ses.py +++ b/tests/common/db/ses.py @@ -17,7 +17,7 @@ from warehouse.email.ses.models import EmailMessage, Event, EventTypes -from .base import WarehouseFactory, FuzzyEmail +from .base import FuzzyEmail, WarehouseFactory class EmailMessageFactory(WarehouseFactory): diff --git a/tests/conftest.py b/tests/conftest.py index bb36311c8f3a..a78380da9f18 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -12,10 +12,10 @@ import os import os.path -from unittest import mock import xmlrpc.client from contextlib import contextmanager +from unittest import mock import alembic.command import click.testing @@ -26,13 +26,13 @@ from pyramid.static import ManifestCacheBuster from pytest_postgresql.factories import ( - init_postgresql_database, drop_postgresql_database, get_config, + init_postgresql_database, ) from sqlalchemy import event -from warehouse import config, admin, static +from warehouse import admin, config, static from warehouse.accounts import services from warehouse.metrics import IMetricsService diff --git a/tests/functional/test_templates.py b/tests/functional/test_templates.py index 3616fd71112b..7343f24bd572 100644 --- a/tests/functional/test_templates.py +++ b/tests/functional/test_templates.py @@ -11,9 +11,11 @@ # limitations under the License. import os -import warehouse + from jinja2 import Environment, FileSystemLoader +import warehouse + def test_templates_for_empty_titles(): """ diff --git a/tests/unit/accounts/test_auth_policy.py b/tests/unit/accounts/test_auth_policy.py index ec1fa31a519b..61faa73d7c6f 100644 --- a/tests/unit/accounts/test_auth_policy.py +++ b/tests/unit/accounts/test_auth_policy.py @@ -10,9 +10,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -import pretend import uuid +import pretend + from pyramid import authentication from pyramid.interfaces import IAuthenticationPolicy from zope.interface.verify import verifyClass diff --git a/tests/unit/accounts/test_core.py b/tests/unit/accounts/test_core.py index 2181a38b1fb4..d144707bd5a1 100644 --- a/tests/unit/accounts/test_core.py +++ b/tests/unit/accounts/test_core.py @@ -18,18 +18,18 @@ from warehouse import accounts from warehouse.accounts.interfaces import ( - IUserService, - ITokenService, IPasswordBreachedService, + ITokenService, + IUserService, ) +from warehouse.accounts.models import DisableReason from warehouse.accounts.services import ( - TokenServiceFactory, HaveIBeenPwnedPasswordBreachedService, + TokenServiceFactory, database_login_factory, ) -from warehouse.accounts.models import DisableReason from warehouse.errors import BasicAuthBreachedPassword -from warehouse.rate_limiting import RateLimit, IRateLimiter +from warehouse.rate_limiting import IRateLimiter, RateLimit class TestLogin: diff --git a/tests/unit/accounts/test_models.py b/tests/unit/accounts/test_models.py index 344b0867a140..35e04e3bdd4f 100644 --- a/tests/unit/accounts/test_models.py +++ b/tests/unit/accounts/test_models.py @@ -15,8 +15,8 @@ from warehouse.accounts.models import User, UserFactory from ...common.db.accounts import ( - UserFactory as DBUserFactory, EmailFactory as DBEmailFactory, + UserFactory as DBUserFactory, ) diff --git a/tests/unit/accounts/test_services.py b/tests/unit/accounts/test_services.py index 3d548fa62ea6..ac1905534137 100644 --- a/tests/unit/accounts/test_services.py +++ b/tests/unit/accounts/test_services.py @@ -23,9 +23,9 @@ from warehouse.accounts import services from warehouse.accounts.interfaces import ( - IUserService, - ITokenService, IPasswordBreachedService, + ITokenService, + IUserService, TokenExpired, TokenInvalid, TokenMissing, @@ -35,7 +35,7 @@ from warehouse.metrics import IMetricsService, NullMetrics from warehouse.rate_limiting.interfaces import IRateLimiter -from ...common.db.accounts import UserFactory, EmailFactory +from ...common.db.accounts import EmailFactory, UserFactory class TestDatabaseUserService: diff --git a/tests/unit/accounts/test_views.py b/tests/unit/accounts/test_views.py index 544f66aee404..f121eb05aabb 100644 --- a/tests/unit/accounts/test_views.py +++ b/tests/unit/accounts/test_views.py @@ -22,9 +22,9 @@ from warehouse.accounts import views from warehouse.accounts.interfaces import ( - IUserService, - ITokenService, IPasswordBreachedService, + ITokenService, + IUserService, TokenExpired, TokenInvalid, TokenMissing, diff --git a/tests/unit/admin/test_core.py b/tests/unit/admin/test_core.py index addcc25b9d90..aea4fcdbbd1c 100644 --- a/tests/unit/admin/test_core.py +++ b/tests/unit/admin/test_core.py @@ -12,8 +12,8 @@ import pretend -from warehouse.accounts import views as accounts_views from warehouse import admin +from warehouse.accounts import views as accounts_views def test_includeme(mock_manifest_cache_buster, monkeypatch): diff --git a/tests/unit/admin/views/test_blacklist.py b/tests/unit/admin/views/test_blacklist.py index 60d066c74f0f..ebed90798b1b 100644 --- a/tests/unit/admin/views/test_blacklist.py +++ b/tests/unit/admin/views/test_blacklist.py @@ -23,11 +23,11 @@ from ....common.db.accounts import UserFactory from ....common.db.packaging import ( + BlacklistedProjectFactory, + FileFactory, ProjectFactory, ReleaseFactory, RoleFactory, - FileFactory, - BlacklistedProjectFactory, ) diff --git a/tests/unit/admin/views/test_emails.py b/tests/unit/admin/views/test_emails.py index d4c3799b2d2d..5df5d5ae76e6 100644 --- a/tests/unit/admin/views/test_emails.py +++ b/tests/unit/admin/views/test_emails.py @@ -12,10 +12,10 @@ import uuid -import pytest import pretend +import pytest -from pyramid.httpexceptions import HTTPNotFound, HTTPBadRequest +from pyramid.httpexceptions import HTTPBadRequest, HTTPNotFound from warehouse.admin.views import emails as views diff --git a/tests/unit/admin/views/test_projects.py b/tests/unit/admin/views/test_projects.py index 5279ac8d4dce..75ca271e3033 100644 --- a/tests/unit/admin/views/test_projects.py +++ b/tests/unit/admin/views/test_projects.py @@ -11,10 +11,10 @@ # limitations under the License. import datetime +import uuid import pretend import pytest -import uuid from pyramid.httpexceptions import HTTPBadRequest, HTTPMovedPermanently, HTTPSeeOther diff --git a/tests/unit/admin/views/test_users.py b/tests/unit/admin/views/test_users.py index 1a772a5c9232..dcfd353ebbf1 100644 --- a/tests/unit/admin/views/test_users.py +++ b/tests/unit/admin/views/test_users.py @@ -10,9 +10,10 @@ # See the License for the specific language governing permissions and # limitations under the License. +import uuid + import pretend import pytest -import uuid from pyramid.httpexceptions import HTTPBadRequest, HTTPNotFound from webob.multidict import MultiDict, NoVars @@ -20,7 +21,7 @@ from warehouse.admin.views import users as views from warehouse.packaging.models import Project -from ....common.db.accounts import User, UserFactory, EmailFactory +from ....common.db.accounts import EmailFactory, User, UserFactory from ....common.db.packaging import JournalEntryFactory, ProjectFactory, RoleFactory diff --git a/tests/unit/email/ses/test_models.py b/tests/unit/email/ses/test_models.py index 0e0d8d2db9bd..63248c391d0c 100644 --- a/tests/unit/email/ses/test_models.py +++ b/tests/unit/email/ses/test_models.py @@ -15,9 +15,9 @@ from warehouse.accounts.models import UnverifyReasons from warehouse.email.ses.models import ( MAX_TRANSIENT_BOUNCES, + EmailMessage, EmailStatus, EmailStatuses, - EmailMessage, ) from ....common.db.accounts import EmailFactory diff --git a/tests/unit/email/ses/test_tasks.py b/tests/unit/email/ses/test_tasks.py index 17ea9ccc2ddc..990fd8561c6c 100644 --- a/tests/unit/email/ses/test_tasks.py +++ b/tests/unit/email/ses/test_tasks.py @@ -13,7 +13,7 @@ import datetime from warehouse.email.ses.models import EmailMessage -from warehouse.email.ses.tasks import CLEANUP_DELIVERED_AFTER, CLEANUP_AFTER, cleanup +from warehouse.email.ses.tasks import CLEANUP_AFTER, CLEANUP_DELIVERED_AFTER, cleanup from ....common.db.ses import EmailMessageFactory diff --git a/tests/unit/email/test_services.py b/tests/unit/email/test_services.py index 33db6610d2e5..8e3754977b20 100644 --- a/tests/unit/email/test_services.py +++ b/tests/unit/email/test_services.py @@ -23,8 +23,8 @@ from warehouse.email.interfaces import IEmailSender from warehouse.email.services import ( EmailMessage, - SMTPEmailSender, SESEmailSender, + SMTPEmailSender, _format_sender, ) from warehouse.email.ses.models import EmailMessage as SESEmailMessage diff --git a/tests/unit/forklift/test_legacy.py b/tests/unit/forklift/test_legacy.py index c41d24964eb1..de07db79e65a 100644 --- a/tests/unit/forklift/test_legacy.py +++ b/tests/unit/forklift/test_legacy.py @@ -30,28 +30,28 @@ from wtforms.form import Form from wtforms.validators import ValidationError +from warehouse.admin.flags import AdminFlag from warehouse.admin.squats import Squat from warehouse.classifiers.models import Classifier from warehouse.forklift import legacy from warehouse.packaging.interfaces import IFileStorage from warehouse.packaging.models import ( - File, - Filename, Dependency, DependencyKind, - Release, + File, + Filename, + JournalEntry, Project, + Release, Role, - JournalEntry, ) -from warehouse.admin.flags import AdminFlag -from ...common.db.accounts import UserFactory, EmailFactory +from ...common.db.accounts import EmailFactory, UserFactory from ...common.db.classifiers import ClassifierFactory from ...common.db.packaging import ( + FileFactory, ProjectFactory, ReleaseFactory, - FileFactory, RoleFactory, ) diff --git a/tests/unit/i18n/test_filters.py b/tests/unit/i18n/test_filters.py index 3dea51319d71..908e4c01bc95 100644 --- a/tests/unit/i18n/test_filters.py +++ b/tests/unit/i18n/test_filters.py @@ -10,9 +10,10 @@ # See the License for the specific language governing permissions and # limitations under the License. +import email.utils + import babel.dates import babel.numbers -import email.utils import pretend from warehouse.i18n import filters diff --git a/tests/unit/legacy/api/test_json.py b/tests/unit/legacy/api/test_json.py index 1dea89554f3b..fbfbb1a67aa7 100644 --- a/tests/unit/legacy/api/test_json.py +++ b/tests/unit/legacy/api/test_json.py @@ -21,10 +21,10 @@ from ....common.db.accounts import UserFactory from ....common.db.packaging import ( - ProjectFactory, - ReleaseFactory, FileFactory, JournalEntryFactory, + ProjectFactory, + ReleaseFactory, ) diff --git a/tests/unit/legacy/api/test_simple.py b/tests/unit/legacy/api/test_simple.py index 7ae7b65214a7..8b3c2b87b1cf 100644 --- a/tests/unit/legacy/api/test_simple.py +++ b/tests/unit/legacy/api/test_simple.py @@ -18,10 +18,10 @@ from ....common.db.accounts import UserFactory from ....common.db.packaging import ( - ProjectFactory, - ReleaseFactory, FileFactory, JournalEntryFactory, + ProjectFactory, + ReleaseFactory, ) diff --git a/tests/unit/legacy/api/xmlrpc/test_cache.py b/tests/unit/legacy/api/xmlrpc/test_cache.py index 24c8a7b33ed0..57ee569492cf 100644 --- a/tests/unit/legacy/api/xmlrpc/test_cache.py +++ b/tests/unit/legacy/api/xmlrpc/test_cache.py @@ -11,20 +11,21 @@ # limitations under the License. import celery -import redis import pretend import pytest +import redis from pyramid.exceptions import ConfigurationError import warehouse.legacy.api.xmlrpc.cache -from warehouse.legacy.api.xmlrpc.cache import services + from warehouse.legacy.api.xmlrpc import cache from warehouse.legacy.api.xmlrpc.cache import ( - cached_return_view, NullXMLRPCCache, RedisLru, RedisXMLRPCCache, + cached_return_view, + services, ) from warehouse.legacy.api.xmlrpc.cache.interfaces import CacheError, IXMLRPCCache diff --git a/tests/unit/legacy/api/xmlrpc/test_xmlrpc.py b/tests/unit/legacy/api/xmlrpc/test_xmlrpc.py index 21c3141c40be..525fe2dff894 100644 --- a/tests/unit/legacy/api/xmlrpc/test_xmlrpc.py +++ b/tests/unit/legacy/api/xmlrpc/test_xmlrpc.py @@ -21,11 +21,11 @@ from .....common.db.accounts import UserFactory from .....common.db.packaging import ( + FileFactory, + JournalEntryFactory, ProjectFactory, ReleaseFactory, - FileFactory, RoleFactory, - JournalEntryFactory, ) diff --git a/tests/unit/manage/test_views.py b/tests/unit/manage/test_views.py index ce3ee6f9c60b..6794e333e9f7 100644 --- a/tests/unit/manage/test_views.py +++ b/tests/unit/manage/test_views.py @@ -22,18 +22,18 @@ from sqlalchemy.orm.exc import NoResultFound from webob.multidict import MultiDict +from warehouse.accounts.interfaces import IPasswordBreachedService, IUserService from warehouse.manage import views -from warehouse.accounts.interfaces import IUserService, IPasswordBreachedService -from warehouse.packaging.models import JournalEntry, Project, File, Role, User +from warehouse.packaging.models import File, JournalEntry, Project, Role, User from warehouse.utils.paginate import paginate_url_factory from warehouse.utils.project import remove_documentation from ...common.db.accounts import EmailFactory from ...common.db.packaging import ( + FileFactory, JournalEntryFactory, ProjectFactory, ReleaseFactory, - FileFactory, RoleFactory, UserFactory, ) diff --git a/tests/unit/metrics/test_event_handlers.py b/tests/unit/metrics/test_event_handlers.py index 1465680341c5..ec335fe0ad6d 100644 --- a/tests/unit/metrics/test_event_handlers.py +++ b/tests/unit/metrics/test_event_handlers.py @@ -17,13 +17,13 @@ import pytest from warehouse.metrics.event_handlers import ( - time_ms, - on_new_request, + on_before_render, + on_before_retry, on_before_traversal, on_context_found, - on_before_render, + on_new_request, on_new_response, - on_before_retry, + time_ms, ) diff --git a/tests/unit/metrics/test_init.py b/tests/unit/metrics/test_init.py index ba22a9e63d3f..1e01d6300cf1 100644 --- a/tests/unit/metrics/test_init.py +++ b/tests/unit/metrics/test_init.py @@ -16,11 +16,11 @@ from pyramid_retry import IBeforeRetry from warehouse.metrics import ( - includeme, - NullMetrics, DataDogMetrics, IMetricsService, + NullMetrics, event_handlers, + includeme, views, ) diff --git a/tests/unit/metrics/test_services.py b/tests/unit/metrics/test_services.py index 6673532e0532..83e73ff8e920 100644 --- a/tests/unit/metrics/test_services.py +++ b/tests/unit/metrics/test_services.py @@ -10,14 +10,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -import pytest import pretend +import pytest from zope.interface.verify import verifyClass from warehouse.metrics import services from warehouse.metrics.interfaces import IMetricsService -from warehouse.metrics.services import NullMetrics, DataDogMetrics +from warehouse.metrics.services import DataDogMetrics, NullMetrics class TestNullMetrics: diff --git a/tests/unit/metrics/test_views.py b/tests/unit/metrics/test_views.py index 5a9d127e3052..1c74b0a5a64d 100644 --- a/tests/unit/metrics/test_views.py +++ b/tests/unit/metrics/test_views.py @@ -10,8 +10,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -import pytest import pretend +import pytest from warehouse.metrics import views diff --git a/tests/unit/packaging/test_init.py b/tests/unit/packaging/test_init.py index 4d89ce5d5979..00466d5675bf 100644 --- a/tests/unit/packaging/test_init.py +++ b/tests/unit/packaging/test_init.py @@ -17,7 +17,7 @@ from warehouse import packaging from warehouse.accounts.models import Email, User -from warehouse.packaging.interfaces import IFileStorage, IDocsStorage +from warehouse.packaging.interfaces import IDocsStorage, IFileStorage from warehouse.packaging.models import File, Project, Release, Role from warehouse.packaging.tasks import compute_trending diff --git a/tests/unit/packaging/test_models.py b/tests/unit/packaging/test_models.py index 601169f57056..5b213926193f 100644 --- a/tests/unit/packaging/test_models.py +++ b/tests/unit/packaging/test_models.py @@ -18,12 +18,12 @@ from pyramid.location import lineage from pyramid.security import Allow -from warehouse.packaging.models import ProjectFactory, Dependency, DependencyKind, File +from warehouse.packaging.models import Dependency, DependencyKind, File, ProjectFactory from ...common.db.packaging import ( + FileFactory as DBFileFactory, ProjectFactory as DBProjectFactory, ReleaseFactory as DBReleaseFactory, - FileFactory as DBFileFactory, RoleFactory as DBRoleFactory, ) diff --git a/tests/unit/packaging/test_search.py b/tests/unit/packaging/test_search.py index c03294b4234d..26ea0a21e433 100644 --- a/tests/unit/packaging/test_search.py +++ b/tests/unit/packaging/test_search.py @@ -11,6 +11,7 @@ # limitations under the License. import datetime + import pretend from warehouse.packaging.search import Project diff --git a/tests/unit/packaging/test_services.py b/tests/unit/packaging/test_services.py index 89541cce490b..769b9a588623 100644 --- a/tests/unit/packaging/test_services.py +++ b/tests/unit/packaging/test_services.py @@ -20,12 +20,12 @@ from zope.interface.verify import verifyClass -from warehouse.packaging.interfaces import IFileStorage, IDocsStorage +from warehouse.packaging.interfaces import IDocsStorage, IFileStorage from warehouse.packaging.services import ( - LocalFileStorage, - S3FileStorage, LocalDocsStorage, + LocalFileStorage, S3DocsStorage, + S3FileStorage, ) diff --git a/tests/unit/packaging/test_views.py b/tests/unit/packaging/test_views.py index 5ea418c6fe61..091e94043635 100644 --- a/tests/unit/packaging/test_views.py +++ b/tests/unit/packaging/test_views.py @@ -21,9 +21,9 @@ from ...common.db.accounts import UserFactory from ...common.db.classifiers import ClassifierFactory from ...common.db.packaging import ( + FileFactory, ProjectFactory, ReleaseFactory, - FileFactory, RoleFactory, ) diff --git a/tests/unit/rate_limiting/test_core.py b/tests/unit/rate_limiting/test_core.py index e4e147c0ca3c..6f64f51e53be 100644 --- a/tests/unit/rate_limiting/test_core.py +++ b/tests/unit/rate_limiting/test_core.py @@ -12,13 +12,13 @@ import datetime -import redis import pretend +import redis from limits import storage from warehouse import rate_limiting -from warehouse.rate_limiting import RateLimiter, DummyRateLimiter, RateLimit +from warehouse.rate_limiting import DummyRateLimiter, RateLimit, RateLimiter class TestRateLimiter: diff --git a/tests/unit/rss/test_views.py b/tests/unit/rss/test_views.py index 978a3b94a873..f4f5edb4221e 100644 --- a/tests/unit/rss/test_views.py +++ b/tests/unit/rss/test_views.py @@ -15,6 +15,7 @@ import pretend from warehouse.rss import views as rss + from ...common.db.packaging import ProjectFactory, ReleaseFactory diff --git a/tests/unit/search/test_tasks.py b/tests/unit/search/test_tasks.py index b89365799dc5..ab95baeecb78 100644 --- a/tests/unit/search/test_tasks.py +++ b/tests/unit/search/test_tasks.py @@ -22,15 +22,15 @@ from first import first import warehouse.search.tasks + from warehouse.search.tasks import ( + SearchLock, + _project_docs, reindex, reindex_project, unindex_project, - _project_docs, - SearchLock, ) - from ...common.db.packaging import ProjectFactory, ReleaseFactory diff --git a/tests/unit/sitemap/test_views.py b/tests/unit/sitemap/test_views.py index 5653328701b8..d4a246a46448 100644 --- a/tests/unit/sitemap/test_views.py +++ b/tests/unit/sitemap/test_views.py @@ -14,6 +14,7 @@ import pytest from warehouse.sitemap import views as sitemap + from ...common.db.accounts import UserFactory from ...common.db.packaging import ProjectFactory diff --git a/tests/unit/test_config.py b/tests/unit/test_config.py index 686f5ea003a9..4c70ce5b6232 100644 --- a/tests/unit/test_config.py +++ b/tests/unit/test_config.py @@ -20,7 +20,7 @@ from warehouse import config from warehouse.errors import BasicAuthBreachedPassword -from warehouse.utils.wsgi import ProxyFixer, VhmRootRemover, HostRewrite +from warehouse.utils.wsgi import HostRewrite, ProxyFixer, VhmRootRemover class TestRequireHTTPSTween: diff --git a/tests/unit/test_db.py b/tests/unit/test_db.py index e82d5468910a..29d6ce6f597c 100644 --- a/tests/unit/test_db.py +++ b/tests/unit/test_db.py @@ -28,12 +28,12 @@ DEFAULT_ISOLATION, DatabaseNotAvailable, ModelBase, - includeme, _configure_alembic, _create_engine, _create_session, _readonly, _reset, + includeme, ) diff --git a/tests/unit/test_forms.py b/tests/unit/test_forms.py index 77b661253ad1..63dd5e722cc2 100644 --- a/tests/unit/test_forms.py +++ b/tests/unit/test_forms.py @@ -15,7 +15,7 @@ from wtforms.validators import StopValidation, ValidationError -from warehouse.forms import Form, DBForm, URIValidator, PasswordStrengthValidator +from warehouse.forms import DBForm, Form, PasswordStrengthValidator, URIValidator class TestURIValidator: diff --git a/tests/unit/test_http.py b/tests/unit/test_http.py index ada7e150e1cc..49b97d9d7124 100644 --- a/tests/unit/test_http.py +++ b/tests/unit/test_http.py @@ -10,8 +10,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -import threading import queue +import threading import pretend diff --git a/tests/unit/test_raven.py b/tests/unit/test_raven.py index 3c42763fc991..bfae658275d2 100644 --- a/tests/unit/test_raven.py +++ b/tests/unit/test_raven.py @@ -10,13 +10,14 @@ # See the License for the specific language governing permissions and # limitations under the License. +from unittest import mock + import pretend import pytest import raven as real_raven from pyramid.tweens import EXCVIEW, INGRESS from raven.middleware import Sentry as SentryMiddleware -from unittest import mock from warehouse import raven diff --git a/tests/unit/test_redirects.py b/tests/unit/test_redirects.py index 6545fc2a920c..6070d62d50c9 100644 --- a/tests/unit/test_redirects.py +++ b/tests/unit/test_redirects.py @@ -13,7 +13,7 @@ import pretend import pytest -from pyramid.httpexceptions import HTTPMovedPermanently, HTTPBadRequest +from pyramid.httpexceptions import HTTPBadRequest, HTTPMovedPermanently from warehouse import redirects diff --git a/tests/unit/test_sanity.py b/tests/unit/test_sanity.py index 5ff04869e279..44909cefc8fd 100644 --- a/tests/unit/test_sanity.py +++ b/tests/unit/test_sanity.py @@ -15,7 +15,7 @@ import pretend import pytest -from pyramid.httpexceptions import HTTPMovedPermanently, HTTPBadRequest +from pyramid.httpexceptions import HTTPBadRequest, HTTPMovedPermanently from pyramid.request import Request from pyramid.response import Response diff --git a/tests/unit/test_sessions.py b/tests/unit/test_sessions.py index 5f9235f37bdf..cb836e5d5895 100644 --- a/tests/unit/test_sessions.py +++ b/tests/unit/test_sessions.py @@ -13,9 +13,9 @@ import time import msgpack -import redis import pretend import pytest +import redis from pyramid import viewderivers diff --git a/tests/unit/test_tasks.py b/tests/unit/test_tasks.py index 4bb18c3a1bc3..42f2b9bcf815 100644 --- a/tests/unit/test_tasks.py +++ b/tests/unit/test_tasks.py @@ -11,7 +11,6 @@ # limitations under the License. from ssl import VerifyMode - from unittest import mock import pretend diff --git a/tests/unit/test_views.py b/tests/unit/test_views.py index 4d8a3e9eab6a..0a91b3a2e53e 100644 --- a/tests/unit/test_views.py +++ b/tests/unit/test_views.py @@ -16,31 +16,30 @@ import pretend import pytest +from pyramid.httpexceptions import HTTPBadRequest, HTTPNotFound, HTTPServiceUnavailable from webob.multidict import MultiDict -from pyramid.httpexceptions import HTTPNotFound, HTTPBadRequest, HTTPServiceUnavailable - from warehouse import views from warehouse.views import ( classifiers, current_user_indicator, + flash_messages, forbidden, + forbidden_include, + force_status, health, httpexception_view, index, - robotstxt, opensearchxml, + robotstxt, search, - stats, - force_status, - flash_messages, - forbidden_include, service_unavailable, + stats, ) from ..common.db.accounts import UserFactory from ..common.db.classifiers import ClassifierFactory -from ..common.db.packaging import ProjectFactory, ReleaseFactory, FileFactory +from ..common.db.packaging import FileFactory, ProjectFactory, ReleaseFactory class TestHTTPExceptionView: diff --git a/tests/unit/utils/test_compression.py b/tests/unit/utils/test_compression.py index 95392b61d42f..ed294ef0b96c 100644 --- a/tests/unit/utils/test_compression.py +++ b/tests/unit/utils/test_compression.py @@ -14,11 +14,13 @@ import pytest from pyramid.response import Response -from webob.acceptparse import AcceptEncodingValidHeader, AcceptEncodingNoHeader +from webob.acceptparse import AcceptEncodingNoHeader, AcceptEncodingValidHeader from webob.response import gzip_app_iter -from warehouse.utils.compression import _compressor as compressor -from warehouse.utils.compression import compression_tween_factory +from warehouse.utils.compression import ( + _compressor as compressor, + compression_tween_factory, +) class TestCompressor: diff --git a/tests/unit/utils/test_project.py b/tests/unit/utils/test_project.py index ab166de7e622..321cfa87c2e5 100644 --- a/tests/unit/utils/test_project.py +++ b/tests/unit/utils/test_project.py @@ -11,23 +11,24 @@ # limitations under the License. import pytest -from pretend import call, call_recorder, stub, raiser + +from pretend import call, call_recorder, raiser, stub from pyramid.httpexceptions import HTTPSeeOther from sqlalchemy.orm import joinedload from warehouse.packaging.models import ( - Project, - Release, Dependency, File, - Role, JournalEntry, + Project, + Release, + Role, ) from warehouse.utils.project import ( confirm_project, destroy_docs, - remove_project, remove_documentation, + remove_project, ) from ...common.db.accounts import UserFactory diff --git a/tests/unit/utils/test_sns.py b/tests/unit/utils/test_sns.py index 35d224eee4be..ad676685934a 100644 --- a/tests/unit/utils/test_sns.py +++ b/tests/unit/utils/test_sns.py @@ -18,22 +18,21 @@ import pytest from cryptography import x509 -from cryptography.x509.oid import NameOID from cryptography.hazmat.backends import default_backend from cryptography.hazmat.primitives import hashes from cryptography.hazmat.primitives.asymmetric import rsa from cryptography.hazmat.primitives.asymmetric.padding import PKCS1v15 from cryptography.hazmat.primitives.serialization import ( Encoding, + NoEncryption, PrivateFormat, PublicFormat, - NoEncryption, load_pem_private_key, load_pem_public_key, ) +from cryptography.x509.oid import NameOID -from warehouse.utils.sns import MessageVerifier, InvalidMessage - +from warehouse.utils.sns import InvalidMessage, MessageVerifier VALID_SIGNATURE = object() diff --git a/warehouse/__main__.py b/warehouse/__main__.py index 6c8e83cff002..09dc353b227f 100644 --- a/warehouse/__main__.py +++ b/warehouse/__main__.py @@ -14,6 +14,5 @@ from warehouse.cli import warehouse - if __name__ == "__main__": sys.exit(warehouse()) diff --git a/warehouse/accounts/forms.py b/warehouse/accounts/forms.py index 725a5e966b53..9fb2f4f940e7 100644 --- a/warehouse/accounts/forms.py +++ b/warehouse/accounts/forms.py @@ -11,9 +11,9 @@ # limitations under the License. import disposable_email_domains +import jinja2 import wtforms import wtforms.fields.html5 -import jinja2 from warehouse import forms from warehouse.accounts.interfaces import TooManyFailedLogins diff --git a/warehouse/accounts/models.py b/warehouse/accounts/models.py index 5d27caf80207..e68cf2e9f1cd 100644 --- a/warehouse/accounts/models.py +++ b/warehouse/accounts/models.py @@ -14,21 +14,23 @@ from citext import CIText from sqlalchemy import ( + Boolean, CheckConstraint, Column, + DateTime, Enum, ForeignKey, Index, - UniqueConstraint, - Boolean, - DateTime, Integer, String, + UniqueConstraint, + orm, + select, + sql, ) -from sqlalchemy import orm, select, sql from sqlalchemy.dialects.postgresql import UUID -from sqlalchemy.orm.exc import NoResultFound from sqlalchemy.ext.hybrid import hybrid_property +from sqlalchemy.orm.exc import NoResultFound from warehouse import db from warehouse.sitemap.models import SitemapMixin diff --git a/warehouse/accounts/services.py b/warehouse/accounts/services.py index b8ff3cce121d..0874196cf51e 100644 --- a/warehouse/accounts/services.py +++ b/warehouse/accounts/services.py @@ -26,9 +26,9 @@ from zope.interface import implementer from warehouse.accounts.interfaces import ( - IUserService, - ITokenService, IPasswordBreachedService, + ITokenService, + IUserService, TokenExpired, TokenInvalid, TokenMissing, @@ -36,10 +36,9 @@ ) from warehouse.accounts.models import Email, User from warehouse.metrics import IMetricsService -from warehouse.rate_limiting import IRateLimiter, DummyRateLimiter +from warehouse.rate_limiting import DummyRateLimiter, IRateLimiter from warehouse.utils.crypto import BadData, SignatureExpired, URLSafeTimedSerializer - logger = logging.getLogger(__name__) PASSWORD_FIELD = "password" diff --git a/warehouse/accounts/views.py b/warehouse/accounts/views.py index 0508ea069507..e9e4bb9bed44 100644 --- a/warehouse/accounts/views.py +++ b/warehouse/accounts/views.py @@ -20,7 +20,7 @@ HTTPSeeOther, HTTPTooManyRequests, ) -from pyramid.security import remember, forget +from pyramid.security import forget, remember from pyramid.view import view_config from sqlalchemy.orm.exc import NoResultFound @@ -32,21 +32,20 @@ ResetPasswordForm, ) from warehouse.accounts.interfaces import ( - IUserService, - ITokenService, IPasswordBreachedService, + ITokenService, + IUserService, TokenExpired, TokenInvalid, TokenMissing, TooManyFailedLogins, ) -from warehouse.accounts.models import User, Email +from warehouse.accounts.models import Email, User from warehouse.cache.origin import origin_cache -from warehouse.email import send_password_reset_email, send_email_verification_email +from warehouse.email import send_email_verification_email, send_password_reset_email from warehouse.packaging.models import Project, Release from warehouse.utils.http import is_safe_url - USER_ID_INSECURE_COOKIE = "user_id__insecure" diff --git a/warehouse/admin/flags.py b/warehouse/admin/flags.py index 7b01a5159c06..267f06a08a7e 100644 --- a/warehouse/admin/flags.py +++ b/warehouse/admin/flags.py @@ -10,7 +10,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from sqlalchemy import Column, Boolean, Text, sql +from sqlalchemy import Boolean, Column, Text, sql from warehouse import db diff --git a/warehouse/admin/squats.py b/warehouse/admin/squats.py index ccb1d68562f4..0b3f562b6bf2 100644 --- a/warehouse/admin/squats.py +++ b/warehouse/admin/squats.py @@ -10,8 +10,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from sqlalchemy import Boolean, Column, DateTime, ForeignKey, Integer -from sqlalchemy import orm, sql +from sqlalchemy import Boolean, Column, DateTime, ForeignKey, Integer, orm, sql from warehouse import db diff --git a/warehouse/admin/views/blacklist.py b/warehouse/admin/views/blacklist.py index e7377589ad81..ed415966a8d8 100644 --- a/warehouse/admin/views/blacklist.py +++ b/warehouse/admin/views/blacklist.py @@ -14,13 +14,13 @@ from packaging.utils import canonicalize_name from paginate_sqlalchemy import SqlalchemyOrmPage as SQLAlchemyORMPage -from pyramid.httpexceptions import HTTPBadRequest, HTTPSeeOther, HTTPNotFound +from pyramid.httpexceptions import HTTPBadRequest, HTTPNotFound, HTTPSeeOther from pyramid.view import view_config from sqlalchemy import func, literal, or_ from sqlalchemy.orm.exc import NoResultFound from warehouse.accounts.models import User -from warehouse.packaging.models import Project, Release, File, Role, BlacklistedProject +from warehouse.packaging.models import BlacklistedProject, File, Project, Release, Role from warehouse.utils.http import is_safe_url from warehouse.utils.paginate import paginate_url_factory from warehouse.utils.project import remove_project diff --git a/warehouse/admin/views/projects.py b/warehouse/admin/views/projects.py index 49c849bb90bc..4226fff7dea2 100644 --- a/warehouse/admin/views/projects.py +++ b/warehouse/admin/views/projects.py @@ -15,16 +15,15 @@ from paginate_sqlalchemy import SqlalchemyOrmPage as SQLAlchemyORMPage from pyramid.httpexceptions import HTTPBadRequest, HTTPMovedPermanently, HTTPSeeOther from pyramid.view import view_config -from sqlalchemy import or_, func - +from sqlalchemy import func, or_ from sqlalchemy.orm import joinedload from sqlalchemy.orm.exc import NoResultFound from warehouse.accounts.models import User -from warehouse.packaging.models import Project, Release, Role, JournalEntry +from warehouse.forklift.legacy import MAX_FILESIZE +from warehouse.packaging.models import JournalEntry, Project, Release, Role from warehouse.utils.paginate import paginate_url_factory from warehouse.utils.project import confirm_project, remove_project -from warehouse.forklift.legacy import MAX_FILESIZE ONE_MB = 1024 * 1024 # bytes diff --git a/warehouse/admin/views/users.py b/warehouse/admin/views/users.py index b1c796777c16..641d549c278a 100644 --- a/warehouse/admin/views/users.py +++ b/warehouse/admin/views/users.py @@ -16,13 +16,13 @@ import wtforms.fields.html5 from paginate_sqlalchemy import SqlalchemyOrmPage as SQLAlchemyORMPage -from pyramid.httpexceptions import HTTPSeeOther, HTTPBadRequest, HTTPNotFound +from pyramid.httpexceptions import HTTPBadRequest, HTTPNotFound, HTTPSeeOther from pyramid.view import view_config from sqlalchemy import or_ from sqlalchemy.orm.exc import NoResultFound from warehouse import forms -from warehouse.accounts.models import User, Email +from warehouse.accounts.models import Email, User from warehouse.packaging.models import JournalEntry, Project, Role from warehouse.utils.paginate import paginate_url_factory diff --git a/warehouse/cache/http.py b/warehouse/cache/http.py index 2482f4b05a3f..8ef906453b58 100644 --- a/warehouse/cache/http.py +++ b/warehouse/cache/http.py @@ -13,7 +13,6 @@ import collections.abc import functools - BUFFER_MAX = 1 * 1024 * 1024 # We'll buffer up to 1MB diff --git a/warehouse/cli/db/branches.py b/warehouse/cli/db/branches.py index 4e8c68ce7867..79e972692112 100644 --- a/warehouse/cli/db/branches.py +++ b/warehouse/cli/db/branches.py @@ -13,7 +13,7 @@ import alembic.command import click -from warehouse.cli.db import db, alembic_lock +from warehouse.cli.db import alembic_lock, db @db.command() diff --git a/warehouse/cli/db/current.py b/warehouse/cli/db/current.py index c3ae487751b0..416ada2f63ad 100644 --- a/warehouse/cli/db/current.py +++ b/warehouse/cli/db/current.py @@ -13,7 +13,7 @@ import alembic.command import click -from warehouse.cli.db import db, alembic_lock +from warehouse.cli.db import alembic_lock, db @db.command() diff --git a/warehouse/cli/db/downgrade.py b/warehouse/cli/db/downgrade.py index 66bd0ce517a5..3bba1c8da10c 100644 --- a/warehouse/cli/db/downgrade.py +++ b/warehouse/cli/db/downgrade.py @@ -13,7 +13,7 @@ import alembic.command import click -from warehouse.cli.db import db, alembic_lock +from warehouse.cli.db import alembic_lock, db @db.command() diff --git a/warehouse/cli/db/heads.py b/warehouse/cli/db/heads.py index a9b743e86c06..1e94a1ab5f7a 100644 --- a/warehouse/cli/db/heads.py +++ b/warehouse/cli/db/heads.py @@ -13,7 +13,7 @@ import alembic.command import click -from warehouse.cli.db import db, alembic_lock +from warehouse.cli.db import alembic_lock, db @db.command() diff --git a/warehouse/cli/db/history.py b/warehouse/cli/db/history.py index c700f8c777bc..dba1bfcc804e 100644 --- a/warehouse/cli/db/history.py +++ b/warehouse/cli/db/history.py @@ -13,7 +13,7 @@ import alembic.command import click -from warehouse.cli.db import db, alembic_lock +from warehouse.cli.db import alembic_lock, db @db.command() diff --git a/warehouse/cli/db/merge.py b/warehouse/cli/db/merge.py index 5e178d322990..089ff548392b 100644 --- a/warehouse/cli/db/merge.py +++ b/warehouse/cli/db/merge.py @@ -13,7 +13,7 @@ import alembic.command import click -from warehouse.cli.db import db, alembic_lock +from warehouse.cli.db import alembic_lock, db @db.command() diff --git a/warehouse/cli/db/revision.py b/warehouse/cli/db/revision.py index 9d45f59a8f74..87355ee9a024 100644 --- a/warehouse/cli/db/revision.py +++ b/warehouse/cli/db/revision.py @@ -13,7 +13,7 @@ import alembic.command import click -from warehouse.cli.db import db, alembic_lock +from warehouse.cli.db import alembic_lock, db @db.command() diff --git a/warehouse/cli/db/show.py b/warehouse/cli/db/show.py index a22bce3541a7..e663361a01f3 100644 --- a/warehouse/cli/db/show.py +++ b/warehouse/cli/db/show.py @@ -13,7 +13,7 @@ import alembic.command import click -from warehouse.cli.db import db, alembic_lock +from warehouse.cli.db import alembic_lock, db @db.command() diff --git a/warehouse/cli/db/stamp.py b/warehouse/cli/db/stamp.py index 3e64f020f638..5a973bd47a70 100644 --- a/warehouse/cli/db/stamp.py +++ b/warehouse/cli/db/stamp.py @@ -13,7 +13,7 @@ import alembic.command import click -from warehouse.cli.db import db, alembic_lock +from warehouse.cli.db import alembic_lock, db @db.command() diff --git a/warehouse/cli/db/upgrade.py b/warehouse/cli/db/upgrade.py index af5b2525e8d2..fba82a565348 100644 --- a/warehouse/cli/db/upgrade.py +++ b/warehouse/cli/db/upgrade.py @@ -13,7 +13,7 @@ import alembic.command import click -from warehouse.cli.db import db, alembic_lock +from warehouse.cli.db import alembic_lock, db @db.command() diff --git a/warehouse/config.py b/warehouse/config.py index 6c04c85511b0..1c76119dd0c5 100644 --- a/warehouse/config.py +++ b/warehouse/config.py @@ -25,7 +25,7 @@ from warehouse.errors import BasicAuthBreachedPassword from warehouse.utils.static import ManifestCacheBuster -from warehouse.utils.wsgi import ProxyFixer, VhmRootRemover, HostRewrite +from warehouse.utils.wsgi import HostRewrite, ProxyFixer, VhmRootRemover class Environment(enum.Enum): diff --git a/warehouse/csp.py b/warehouse/csp.py index 89a29d22f487..c22c88aa98f1 100644 --- a/warehouse/csp.py +++ b/warehouse/csp.py @@ -13,7 +13,6 @@ import collections import copy - SELF = "'self'" NONE = "'none'" diff --git a/warehouse/csrf.py b/warehouse/csrf.py index 35a0a23dec17..c9656476907a 100644 --- a/warehouse/csrf.py +++ b/warehouse/csrf.py @@ -13,7 +13,6 @@ from pyramid.httpexceptions import HTTPMethodNotAllowed from pyramid.viewderivers import INGRESS, csrf_view - SAFE_METHODS = {"GET", "HEAD", "OPTIONS"} diff --git a/warehouse/db.py b/warehouse/db.py index e056bb817d16..89de8b7daaaa 100644 --- a/warehouse/db.py +++ b/warehouse/db.py @@ -30,7 +30,6 @@ from warehouse.metrics import IMetricsService from warehouse.utils.attrs import make_repr - __all__ = ["includeme", "metadata", "ModelBase"] diff --git a/warehouse/email/ses/models.py b/warehouse/email/ses/models.py index a5c2ea0c3a7d..c06ac64d0670 100644 --- a/warehouse/email/ses/models.py +++ b/warehouse/email/ses/models.py @@ -14,8 +14,7 @@ import automat -from sqlalchemy import sql, orm -from sqlalchemy import Boolean, Column, Enum, ForeignKey, DateTime, Text +from sqlalchemy import Boolean, Column, DateTime, Enum, ForeignKey, Text, orm, sql from sqlalchemy.dialects.postgresql import JSONB, UUID from sqlalchemy.ext.mutable import MutableDict from sqlalchemy.orm.session import object_session @@ -23,7 +22,6 @@ from warehouse import db from warehouse.accounts.models import Email as EmailAddress, UnverifyReasons - MAX_TRANSIENT_BOUNCES = 5 diff --git a/warehouse/email/ses/tasks.py b/warehouse/email/ses/tasks.py index 2651627da362..33581594adbf 100644 --- a/warehouse/email/ses/tasks.py +++ b/warehouse/email/ses/tasks.py @@ -15,7 +15,6 @@ from warehouse import tasks from warehouse.email.ses.models import EmailMessage - CLEANUP_DELIVERED_AFTER = datetime.timedelta(days=14) CLEANUP_AFTER = datetime.timedelta(days=90) diff --git a/warehouse/filters.py b/warehouse/filters.py index 5a4d820924c4..37486ecbc5e2 100644 --- a/warehouse/filters.py +++ b/warehouse/filters.py @@ -22,7 +22,6 @@ import html5lib.serializer import html5lib.treewalkers import jinja2 - import packaging.version from pyramid.threadlocal import get_current_request diff --git a/warehouse/forklift/legacy.py b/warehouse/forklift/legacy.py index 6e69d66fe8ec..910b34fef393 100644 --- a/warehouse/forklift/legacy.py +++ b/warehouse/forklift/legacy.py @@ -17,13 +17,12 @@ import re import tempfile import zipfile -from cgi import parse_header -from cgi import FieldStorage +from cgi import FieldStorage, parse_header from itertools import chain -import packaging.specifiers import packaging.requirements +import packaging.specifiers import packaging.utils import packaging.version import pkg_resources @@ -43,19 +42,18 @@ from warehouse.classifiers.models import Classifier from warehouse.packaging.interfaces import IFileStorage from warehouse.packaging.models import ( - Project, - Release, + BlacklistedProject, Dependency, DependencyKind, - Role, File, Filename, JournalEntry, - BlacklistedProject, + Project, + Release, + Role, ) from warehouse.utils import http - MAX_FILESIZE = 60 * 1024 * 1024 # 60M MAX_SIGSIZE = 8 * 1024 # 8K diff --git a/warehouse/http.py b/warehouse/http.py index d035f75e51b9..ccc13f7d87fc 100644 --- a/warehouse/http.py +++ b/warehouse/http.py @@ -11,6 +11,7 @@ # limitations under the License. import threading + import requests from requests.adapters import HTTPAdapter diff --git a/warehouse/i18n/filters.py b/warehouse/i18n/filters.py index f31ae20cafa1..3b57998204e9 100644 --- a/warehouse/i18n/filters.py +++ b/warehouse/i18n/filters.py @@ -10,9 +10,10 @@ # See the License for the specific language governing permissions and # limitations under the License. +import email.utils + import babel.dates import babel.numbers -import email.utils import jinja2 from pyramid.threadlocal import get_current_request diff --git a/warehouse/legacy/api/json.py b/warehouse/legacy/api/json.py index 543682967b0a..601f04804422 100644 --- a/warehouse/legacy/api/json.py +++ b/warehouse/legacy/api/json.py @@ -19,8 +19,7 @@ from warehouse.cache.http import cache_control from warehouse.cache.origin import origin_cache -from warehouse.packaging.models import File, Release, Project - +from warehouse.packaging.models import File, Project, Release # Generate appropriate CORS headers for the JSON endpoint. # We want to allow Cross-Origin requests here so that users can interact diff --git a/warehouse/legacy/api/simple.py b/warehouse/legacy/api/simple.py index 3fc696b66a1d..b511f4d4bf05 100644 --- a/warehouse/legacy/api/simple.py +++ b/warehouse/legacy/api/simple.py @@ -19,7 +19,7 @@ from warehouse.cache.http import cache_control from warehouse.cache.origin import origin_cache -from warehouse.packaging.models import JournalEntry, File, Project, Release +from warehouse.packaging.models import File, JournalEntry, Project, Release @view_config( diff --git a/warehouse/legacy/api/xmlrpc/cache/fncache.py b/warehouse/legacy/api/xmlrpc/cache/fncache.py index b6a820d00908..348c33905442 100644 --- a/warehouse/legacy/api/xmlrpc/cache/fncache.py +++ b/warehouse/legacy/api/xmlrpc/cache/fncache.py @@ -11,6 +11,7 @@ # limitations under the License. import json + import redis from warehouse.legacy.api.xmlrpc.cache.interfaces import CacheError diff --git a/warehouse/legacy/api/xmlrpc/views.py b/warehouse/legacy/api/xmlrpc/views.py index cd1ddc16da4a..5ac0b325fe1a 100644 --- a/warehouse/legacy/api/xmlrpc/views.py +++ b/warehouse/legacy/api/xmlrpc/views.py @@ -37,11 +37,11 @@ from warehouse.classifiers.models import Classifier from warehouse.metrics import IMetricsService from warehouse.packaging.models import ( - Role, - Project, - Release, File, JournalEntry, + Project, + Release, + Role, release_classifiers, ) from warehouse.search.queries import SEARCH_BOOSTS diff --git a/warehouse/manage/views.py b/warehouse/manage/views.py index 434718262fe6..03a066805519 100644 --- a/warehouse/manage/views.py +++ b/warehouse/manage/views.py @@ -19,8 +19,8 @@ from sqlalchemy.orm import joinedload from sqlalchemy.orm.exc import NoResultFound -from warehouse.accounts.interfaces import IUserService, IPasswordBreachedService -from warehouse.accounts.models import User, Email +from warehouse.accounts.interfaces import IPasswordBreachedService, IUserService +from warehouse.accounts.models import Email, User from warehouse.accounts.views import logout from warehouse.email import ( send_account_deletion_email, @@ -33,8 +33,8 @@ from warehouse.manage.forms import ( AddEmailForm, ChangePasswordForm, - CreateRoleForm, ChangeRoleForm, + CreateRoleForm, SaveAccountForm, ) from warehouse.packaging.models import File, JournalEntry, Project, Release, Role diff --git a/warehouse/migrations/versions/039f45e2dbf9_record_when_the_password_was_set.py b/warehouse/migrations/versions/039f45e2dbf9_record_when_the_password_was_set.py index 079239254943..8a5f407cfc49 100644 --- a/warehouse/migrations/versions/039f45e2dbf9_record_when_the_password_was_set.py +++ b/warehouse/migrations/versions/039f45e2dbf9_record_when_the_password_was_set.py @@ -17,9 +17,9 @@ Create Date: 2016-06-15 13:10:02.361621 """ -from alembic import op import sqlalchemy as sa +from alembic import op revision = "039f45e2dbf9" down_revision = "a65114e48d6f" diff --git a/warehouse/migrations/versions/06bfbc92f67d_rename_tables.py b/warehouse/migrations/versions/06bfbc92f67d_rename_tables.py index 24f4eba3f453..805233ee2381 100644 --- a/warehouse/migrations/versions/06bfbc92f67d_rename_tables.py +++ b/warehouse/migrations/versions/06bfbc92f67d_rename_tables.py @@ -19,7 +19,6 @@ from alembic import op - revision = "06bfbc92f67d" down_revision = "e612a92c1017" diff --git a/warehouse/migrations/versions/08447ab49999_optimize_queries.py b/warehouse/migrations/versions/08447ab49999_optimize_queries.py index e999ef7d99e2..4c489dba2fa3 100644 --- a/warehouse/migrations/versions/08447ab49999_optimize_queries.py +++ b/warehouse/migrations/versions/08447ab49999_optimize_queries.py @@ -19,7 +19,6 @@ from alembic import op - revision = "08447ab49999" down_revision = "06bfbc92f67d" diff --git a/warehouse/migrations/versions/0864352e2168_drop_duplicate_indexes.py b/warehouse/migrations/versions/0864352e2168_drop_duplicate_indexes.py index 3a43ed46620c..7d58b9438348 100644 --- a/warehouse/migrations/versions/0864352e2168_drop_duplicate_indexes.py +++ b/warehouse/migrations/versions/0864352e2168_drop_duplicate_indexes.py @@ -19,7 +19,6 @@ from alembic import op - revision = "0864352e2168" down_revision = "6a6eb0a95603" diff --git a/warehouse/migrations/versions/0977b97fce94_add_file_blake2_256_digest.py b/warehouse/migrations/versions/0977b97fce94_add_file_blake2_256_digest.py index a09e85cc0d3c..b1a6c789b90e 100644 --- a/warehouse/migrations/versions/0977b97fce94_add_file_blake2_256_digest.py +++ b/warehouse/migrations/versions/0977b97fce94_add_file_blake2_256_digest.py @@ -22,7 +22,6 @@ from alembic import op - revision = "0977b97fce94" down_revision = "f46672a776f1" diff --git a/warehouse/migrations/versions/104b4c56862b_denormalize_serial_onto_project.py b/warehouse/migrations/versions/104b4c56862b_denormalize_serial_onto_project.py index 9723198b8c37..2f5dbc6f8d1c 100644 --- a/warehouse/migrations/versions/104b4c56862b_denormalize_serial_onto_project.py +++ b/warehouse/migrations/versions/104b4c56862b_denormalize_serial_onto_project.py @@ -17,9 +17,9 @@ Create Date: 2016-05-04 21:47:04.133779 """ -from alembic import op import sqlalchemy as sa +from alembic import op revision = "104b4c56862b" down_revision = "fb3278418206" diff --git a/warehouse/migrations/versions/10cb17aea73_default_hosting_mode_to_pypi_only.py b/warehouse/migrations/versions/10cb17aea73_default_hosting_mode_to_pypi_only.py index 29645731f7e9..765c7c0ff527 100644 --- a/warehouse/migrations/versions/10cb17aea73_default_hosting_mode_to_pypi_only.py +++ b/warehouse/migrations/versions/10cb17aea73_default_hosting_mode_to_pypi_only.py @@ -19,7 +19,6 @@ from alembic import op - revision = "10cb17aea73" down_revision = "41abd35caa3" diff --git a/warehouse/migrations/versions/111d8fc0443_use_enums_instead_of_text.py b/warehouse/migrations/versions/111d8fc0443_use_enums_instead_of_text.py index 91e91b3e9734..3aca6b57473a 100644 --- a/warehouse/migrations/versions/111d8fc0443_use_enums_instead_of_text.py +++ b/warehouse/migrations/versions/111d8fc0443_use_enums_instead_of_text.py @@ -20,7 +20,6 @@ from alembic import op from sqlalchemy.dialects.postgresql import ENUM - revision = "111d8fc0443" down_revision = "5988e3e8d2e" diff --git a/warehouse/migrations/versions/116be7c87e1_add_a_sitemap_bucket_column_to_user.py b/warehouse/migrations/versions/116be7c87e1_add_a_sitemap_bucket_column_to_user.py index d148f1ec1970..06cd8e648f53 100644 --- a/warehouse/migrations/versions/116be7c87e1_add_a_sitemap_bucket_column_to_user.py +++ b/warehouse/migrations/versions/116be7c87e1_add_a_sitemap_bucket_column_to_user.py @@ -17,9 +17,9 @@ Create Date: 2015-09-06 20:28:24.073366 """ -from alembic import op import sqlalchemy as sa +from alembic import op revision = "116be7c87e1" down_revision = "5345b1bc8b9" diff --git a/warehouse/migrations/versions/128a0ead322_add_primary_key_roles.py b/warehouse/migrations/versions/128a0ead322_add_primary_key_roles.py index 3e9691f2fe5e..f23b4ed3b582 100644 --- a/warehouse/migrations/versions/128a0ead322_add_primary_key_roles.py +++ b/warehouse/migrations/versions/128a0ead322_add_primary_key_roles.py @@ -17,8 +17,9 @@ Create Date: 2015-02-18 18:48:23.131652 """ -from alembic import op import sqlalchemy as sa + +from alembic import op from sqlalchemy.dialects import postgresql revision = "128a0ead322" diff --git a/warehouse/migrations/versions/18e4cf2bb3e_create_openid_connect_sub_column_for_.py b/warehouse/migrations/versions/18e4cf2bb3e_create_openid_connect_sub_column_for_.py index 45140bcaed17..51d63936a9b4 100644 --- a/warehouse/migrations/versions/18e4cf2bb3e_create_openid_connect_sub_column_for_.py +++ b/warehouse/migrations/versions/18e4cf2bb3e_create_openid_connect_sub_column_for_.py @@ -17,9 +17,9 @@ Create Date: 2015-11-07 22:43:21.589230 """ -from alembic import op import sqlalchemy as sa +from alembic import op revision = "18e4cf2bb3e" down_revision = "116be7c87e1" diff --git a/warehouse/migrations/versions/1ce6d45d7ef_readd_the_unique_constraint_on_pep426_.py b/warehouse/migrations/versions/1ce6d45d7ef_readd_the_unique_constraint_on_pep426_.py index 44d1c9e1a55a..ddf59d88d706 100644 --- a/warehouse/migrations/versions/1ce6d45d7ef_readd_the_unique_constraint_on_pep426_.py +++ b/warehouse/migrations/versions/1ce6d45d7ef_readd_the_unique_constraint_on_pep426_.py @@ -19,7 +19,6 @@ from alembic import op - revision = "1ce6d45d7ef" down_revision = "23a3c4ffe5d" diff --git a/warehouse/migrations/versions/1e2ccd34f539_move_existing_blacklisted_projects_into_.py b/warehouse/migrations/versions/1e2ccd34f539_move_existing_blacklisted_projects_into_.py index 4adc20b90fea..38c593711a1b 100644 --- a/warehouse/migrations/versions/1e2ccd34f539_move_existing_blacklisted_projects_into_.py +++ b/warehouse/migrations/versions/1e2ccd34f539_move_existing_blacklisted_projects_into_.py @@ -19,7 +19,6 @@ from alembic import op - revision = "1e2ccd34f539" down_revision = "b6a20b9c888d" diff --git a/warehouse/migrations/versions/1f002cab0a7_add_size_signature_and_docs.py b/warehouse/migrations/versions/1f002cab0a7_add_size_signature_and_docs.py index 12b588f28355..e6994f3b67c0 100644 --- a/warehouse/migrations/versions/1f002cab0a7_add_size_signature_and_docs.py +++ b/warehouse/migrations/versions/1f002cab0a7_add_size_signature_and_docs.py @@ -17,9 +17,9 @@ Create Date: 2015-06-02 23:50:02.029186 """ -from alembic import op import sqlalchemy as sa +from alembic import op revision = "1f002cab0a7" down_revision = "283c68f2ab2" diff --git a/warehouse/migrations/versions/1fdf5dc6bbf3_data_migration_for_canonical_version_.py b/warehouse/migrations/versions/1fdf5dc6bbf3_data_migration_for_canonical_version_.py index d89a4b5d77e5..031396a4b107 100644 --- a/warehouse/migrations/versions/1fdf5dc6bbf3_data_migration_for_canonical_version_.py +++ b/warehouse/migrations/versions/1fdf5dc6bbf3_data_migration_for_canonical_version_.py @@ -17,10 +17,10 @@ Create Date: 2018-02-28 22:40:42.495355 """ -from alembic import op import sqlalchemy as sa -from packaging.utils import canonicalize_version +from alembic import op +from packaging.utils import canonicalize_version revision = "1fdf5dc6bbf3" down_revision = "f7577b6938c1" diff --git a/warehouse/migrations/versions/23a3c4ffe5d_relax_normalization_rules.py b/warehouse/migrations/versions/23a3c4ffe5d_relax_normalization_rules.py index d3a819685c14..4e981c5c7bfc 100644 --- a/warehouse/migrations/versions/23a3c4ffe5d_relax_normalization_rules.py +++ b/warehouse/migrations/versions/23a3c4ffe5d_relax_normalization_rules.py @@ -19,7 +19,6 @@ from alembic import op - revision = "23a3c4ffe5d" down_revision = "91508cc5c2" diff --git a/warehouse/migrations/versions/2730e54f8717_reset_classifier_id_sequence.py b/warehouse/migrations/versions/2730e54f8717_reset_classifier_id_sequence.py index 7ba4692b57a8..ec0b1e288984 100644 --- a/warehouse/migrations/versions/2730e54f8717_reset_classifier_id_sequence.py +++ b/warehouse/migrations/versions/2730e54f8717_reset_classifier_id_sequence.py @@ -19,7 +19,6 @@ from alembic import op - revision = "2730e54f8717" down_revision = "8fd3400c760f" diff --git a/warehouse/migrations/versions/283c68f2ab2_initial_migration.py b/warehouse/migrations/versions/283c68f2ab2_initial_migration.py index f3d815a07311..02240ec87ff5 100644 --- a/warehouse/migrations/versions/283c68f2ab2_initial_migration.py +++ b/warehouse/migrations/versions/283c68f2ab2_initial_migration.py @@ -17,11 +17,10 @@ Create Date: 2015-02-01 14:07:10.983672 """ -from alembic import op - import citext import sqlalchemy as sa +from alembic import op revision = "283c68f2ab2" down_revision = None diff --git a/warehouse/migrations/versions/28a7e805fd0_drop_denormalized_normalized_name_field.py b/warehouse/migrations/versions/28a7e805fd0_drop_denormalized_normalized_name_field.py index 94ec08761f1b..ed305136c093 100644 --- a/warehouse/migrations/versions/28a7e805fd0_drop_denormalized_normalized_name_field.py +++ b/warehouse/migrations/versions/28a7e805fd0_drop_denormalized_normalized_name_field.py @@ -19,7 +19,6 @@ from alembic import op - revision = "28a7e805fd0" down_revision = "91508cc5c2" diff --git a/warehouse/migrations/versions/29d87a24d79e_cascade_project_deletion_to_release.py b/warehouse/migrations/versions/29d87a24d79e_cascade_project_deletion_to_release.py index 462d34df8f2c..42425df5c082 100644 --- a/warehouse/migrations/versions/29d87a24d79e_cascade_project_deletion_to_release.py +++ b/warehouse/migrations/versions/29d87a24d79e_cascade_project_deletion_to_release.py @@ -19,7 +19,6 @@ from alembic import op - revision = "29d87a24d79e" down_revision = "c0682028c857" diff --git a/warehouse/migrations/versions/2d6390eebe90_fix_typo.py b/warehouse/migrations/versions/2d6390eebe90_fix_typo.py index 8f0eb2d241d7..4274672e6054 100644 --- a/warehouse/migrations/versions/2d6390eebe90_fix_typo.py +++ b/warehouse/migrations/versions/2d6390eebe90_fix_typo.py @@ -19,7 +19,6 @@ from alembic import op - revision = "2d6390eebe90" down_revision = "08447ab49999" diff --git a/warehouse/migrations/versions/312040efcfe_default_upload_time_to_now.py b/warehouse/migrations/versions/312040efcfe_default_upload_time_to_now.py index 5eb37aa075fb..4873110b1524 100644 --- a/warehouse/migrations/versions/312040efcfe_default_upload_time_to_now.py +++ b/warehouse/migrations/versions/312040efcfe_default_upload_time_to_now.py @@ -17,9 +17,9 @@ Create Date: 2015-06-13 01:44:23.445650 """ -from alembic import op import sqlalchemy as sa +from alembic import op revision = "312040efcfe" down_revision = "57b1053998d" diff --git a/warehouse/migrations/versions/3af8d0006ba_normalize_runs_of_characters_to_a_.py b/warehouse/migrations/versions/3af8d0006ba_normalize_runs_of_characters_to_a_.py index 9ebeb48954eb..9d3268df3d87 100644 --- a/warehouse/migrations/versions/3af8d0006ba_normalize_runs_of_characters_to_a_.py +++ b/warehouse/migrations/versions/3af8d0006ba_normalize_runs_of_characters_to_a_.py @@ -19,7 +19,6 @@ from alembic import op - revision = "3af8d0006ba" down_revision = "5ff0c99c94" diff --git a/warehouse/migrations/versions/3bc5176b880_add_a_table_to_maintain_a_count_of_.py b/warehouse/migrations/versions/3bc5176b880_add_a_table_to_maintain_a_count_of_.py index eb20e0bb8b2a..54c9bb1fcbc2 100644 --- a/warehouse/migrations/versions/3bc5176b880_add_a_table_to_maintain_a_count_of_.py +++ b/warehouse/migrations/versions/3bc5176b880_add_a_table_to_maintain_a_count_of_.py @@ -17,8 +17,9 @@ Create Date: 2015-11-15 15:10:38.681814 """ -from alembic import op import sqlalchemy as sa + +from alembic import op from sqlalchemy.dialects import postgresql revision = "3bc5176b880" diff --git a/warehouse/migrations/versions/3d2b8a42219a_add_a_flag_for_legacy_file_support.py b/warehouse/migrations/versions/3d2b8a42219a_add_a_flag_for_legacy_file_support.py index 47985dfb8662..cd358395369f 100644 --- a/warehouse/migrations/versions/3d2b8a42219a_add_a_flag_for_legacy_file_support.py +++ b/warehouse/migrations/versions/3d2b8a42219a_add_a_flag_for_legacy_file_support.py @@ -17,9 +17,9 @@ Create Date: 2016-09-02 18:03:06.175231 """ -from alembic import op import sqlalchemy as sa +from alembic import op revision = "3d2b8a42219a" down_revision = "8c8be2c0e69e" diff --git a/warehouse/migrations/versions/41abd35caa3_add_index_on_release_created.py b/warehouse/migrations/versions/41abd35caa3_add_index_on_release_created.py index b99b0f1060a1..519f3e2c2827 100644 --- a/warehouse/migrations/versions/41abd35caa3_add_index_on_release_created.py +++ b/warehouse/migrations/versions/41abd35caa3_add_index_on_release_created.py @@ -17,9 +17,9 @@ Create Date: 2015-08-24 23:16:07.674157 """ -from alembic import op import sqlalchemy as sa +from alembic import op revision = "41abd35caa3" down_revision = "3af8d0006ba" diff --git a/warehouse/migrations/versions/41e9207fbe5_remove_the_description_html_column.py b/warehouse/migrations/versions/41e9207fbe5_remove_the_description_html_column.py index 78c5826dda37..338faefc865a 100644 --- a/warehouse/migrations/versions/41e9207fbe5_remove_the_description_html_column.py +++ b/warehouse/migrations/versions/41e9207fbe5_remove_the_description_html_column.py @@ -19,7 +19,6 @@ from alembic import op - revision = "41e9207fbe5" down_revision = "49b93c346db" diff --git a/warehouse/migrations/versions/477bc785c999_add_a_server_default_for_submitted_date.py b/warehouse/migrations/versions/477bc785c999_add_a_server_default_for_submitted_date.py index 8b1a825674b3..234c4247e9d1 100644 --- a/warehouse/migrations/versions/477bc785c999_add_a_server_default_for_submitted_date.py +++ b/warehouse/migrations/versions/477bc785c999_add_a_server_default_for_submitted_date.py @@ -17,8 +17,9 @@ Create Date: 2015-12-16 16:19:59.419186 """ -from alembic import op import sqlalchemy as sa + +from alembic import op from sqlalchemy.dialects import postgresql revision = "477bc785c999" diff --git a/warehouse/migrations/versions/4e7d5154cb0c_add_a_column_for_tracking_why_a_user_.py b/warehouse/migrations/versions/4e7d5154cb0c_add_a_column_for_tracking_why_a_user_.py index 928e4d2f8381..005fd70cbd2a 100644 --- a/warehouse/migrations/versions/4e7d5154cb0c_add_a_column_for_tracking_why_a_user_.py +++ b/warehouse/migrations/versions/4e7d5154cb0c_add_a_column_for_tracking_why_a_user_.py @@ -17,9 +17,9 @@ Create Date: 2018-08-14 01:20:03.996141 """ -from alembic import op import sqlalchemy as sa +from alembic import op revision = "4e7d5154cb0c" down_revision = "68a00c174ba5" diff --git a/warehouse/migrations/versions/4ec0adada10_add_function_to_convert_string_to_bucket.py b/warehouse/migrations/versions/4ec0adada10_add_function_to_convert_string_to_bucket.py index 386835fcf00c..3a1f96570ffb 100644 --- a/warehouse/migrations/versions/4ec0adada10_add_function_to_convert_string_to_bucket.py +++ b/warehouse/migrations/versions/4ec0adada10_add_function_to_convert_string_to_bucket.py @@ -19,7 +19,6 @@ from alembic import op - revision = "4ec0adada10" down_revision = "9177113533" diff --git a/warehouse/migrations/versions/522918187b73_drop_indexes_that_are_a_subset_of_.py b/warehouse/migrations/versions/522918187b73_drop_indexes_that_are_a_subset_of_.py index a14b13928aed..aebdec9a834a 100644 --- a/warehouse/migrations/versions/522918187b73_drop_indexes_that_are_a_subset_of_.py +++ b/warehouse/migrations/versions/522918187b73_drop_indexes_that_are_a_subset_of_.py @@ -19,7 +19,6 @@ from alembic import op - revision = "522918187b73" down_revision = "0864352e2168" diff --git a/warehouse/migrations/versions/5345b1bc8b9_add_a_sitemap_bucket_column_to_project.py b/warehouse/migrations/versions/5345b1bc8b9_add_a_sitemap_bucket_column_to_project.py index f123194d4396..7616f3dbd370 100644 --- a/warehouse/migrations/versions/5345b1bc8b9_add_a_sitemap_bucket_column_to_project.py +++ b/warehouse/migrations/versions/5345b1bc8b9_add_a_sitemap_bucket_column_to_project.py @@ -17,9 +17,9 @@ Create Date: 2015-09-06 19:56:58.188767 """ -from alembic import op import sqlalchemy as sa +from alembic import op revision = "5345b1bc8b9" down_revision = "4ec0adada10" diff --git a/warehouse/migrations/versions/5538f2d929dd_move_all_user_fks_to_id_instead_of_.py b/warehouse/migrations/versions/5538f2d929dd_move_all_user_fks_to_id_instead_of_.py index b88a9f6df202..c0758f47de53 100644 --- a/warehouse/migrations/versions/5538f2d929dd_move_all_user_fks_to_id_instead_of_.py +++ b/warehouse/migrations/versions/5538f2d929dd_move_all_user_fks_to_id_instead_of_.py @@ -17,12 +17,11 @@ Create Date: 2018-11-06 08:16:12.099174 """ -from alembic import op import sqlalchemy as sa +from alembic import op from sqlalchemy.dialects import postgresql - revision = "5538f2d929dd" down_revision = "ee5b8f66a223" diff --git a/warehouse/migrations/versions/56e9e630c748_add_fuzzystrmatch.py b/warehouse/migrations/versions/56e9e630c748_add_fuzzystrmatch.py index 5382ff9f6fc7..9f950c298673 100644 --- a/warehouse/migrations/versions/56e9e630c748_add_fuzzystrmatch.py +++ b/warehouse/migrations/versions/56e9e630c748_add_fuzzystrmatch.py @@ -19,7 +19,6 @@ from alembic import op - revision = "56e9e630c748" down_revision = "e82c3a017d60" diff --git a/warehouse/migrations/versions/5988e3e8d2e_add_primary_key_to_release_files.py b/warehouse/migrations/versions/5988e3e8d2e_add_primary_key_to_release_files.py index 9ba07ee1751b..af0de3131ec4 100644 --- a/warehouse/migrations/versions/5988e3e8d2e_add_primary_key_to_release_files.py +++ b/warehouse/migrations/versions/5988e3e8d2e_add_primary_key_to_release_files.py @@ -17,8 +17,9 @@ Create Date: 2015-03-08 21:08:16.285082 """ -from alembic import op import sqlalchemy as sa + +from alembic import op from sqlalchemy.dialects import postgresql revision = "5988e3e8d2e" diff --git a/warehouse/migrations/versions/5b3f9e687d94_add_a_column_to_project_to_record_the_.py b/warehouse/migrations/versions/5b3f9e687d94_add_a_column_to_project_to_record_the_.py index 0c68a813ced9..dd68c4c4ab7e 100644 --- a/warehouse/migrations/versions/5b3f9e687d94_add_a_column_to_project_to_record_the_.py +++ b/warehouse/migrations/versions/5b3f9e687d94_add_a_column_to_project_to_record_the_.py @@ -17,9 +17,9 @@ Create Date: 2017-03-10 02:14:12.402080 """ -from alembic import op import sqlalchemy as sa +from alembic import op revision = "5b3f9e687d94" down_revision = "7750037b351a" diff --git a/warehouse/migrations/versions/5dda74213989_add_description_content_type_field.py b/warehouse/migrations/versions/5dda74213989_add_description_content_type_field.py index 703a69c8a520..1f5650b47b03 100644 --- a/warehouse/migrations/versions/5dda74213989_add_description_content_type_field.py +++ b/warehouse/migrations/versions/5dda74213989_add_description_content_type_field.py @@ -17,9 +17,9 @@ Create Date: 2017-09-08 21:15:55.822175 """ -from alembic import op import sqlalchemy as sa +from alembic import op revision = "5dda74213989" down_revision = "2730e54f8717" diff --git a/warehouse/migrations/versions/5ff0c99c94_add_primary_key_to_dependency.py b/warehouse/migrations/versions/5ff0c99c94_add_primary_key_to_dependency.py index f26f96252ccc..e02ed21d7f19 100644 --- a/warehouse/migrations/versions/5ff0c99c94_add_primary_key_to_dependency.py +++ b/warehouse/migrations/versions/5ff0c99c94_add_primary_key_to_dependency.py @@ -17,8 +17,9 @@ Create Date: 2015-07-20 19:50:55.153532 """ -from alembic import op import sqlalchemy as sa + +from alembic import op from sqlalchemy.dialects import postgresql revision = "5ff0c99c94" diff --git a/warehouse/migrations/versions/62f6becc7653_set_user_is_staff_to_nullable.py b/warehouse/migrations/versions/62f6becc7653_set_user_is_staff_to_nullable.py index 782d557832e7..9811b67274ec 100644 --- a/warehouse/migrations/versions/62f6becc7653_set_user_is_staff_to_nullable.py +++ b/warehouse/migrations/versions/62f6becc7653_set_user_is_staff_to_nullable.py @@ -19,7 +19,6 @@ from alembic import op - revision = "62f6becc7653" down_revision = "522918187b73" diff --git a/warehouse/migrations/versions/6418f7d86a4b_add_read_only_adminflag.py b/warehouse/migrations/versions/6418f7d86a4b_add_read_only_adminflag.py index 2c17bc13c81c..05bae2284604 100644 --- a/warehouse/migrations/versions/6418f7d86a4b_add_read_only_adminflag.py +++ b/warehouse/migrations/versions/6418f7d86a4b_add_read_only_adminflag.py @@ -19,7 +19,6 @@ from alembic import op - revision = "6418f7d86a4b" down_revision = "bf73e785eed9" diff --git a/warehouse/migrations/versions/6714f3f04f0f_add_a_column_to_track_if_the_email_was_.py b/warehouse/migrations/versions/6714f3f04f0f_add_a_column_to_track_if_the_email_was_.py index 8d153a51a45c..f8e1e01c0930 100644 --- a/warehouse/migrations/versions/6714f3f04f0f_add_a_column_to_track_if_the_email_was_.py +++ b/warehouse/migrations/versions/6714f3f04f0f_add_a_column_to_track_if_the_email_was_.py @@ -17,9 +17,9 @@ Create Date: 2018-04-15 06:05:36.949018 """ -from alembic import op import sqlalchemy as sa +from alembic import op revision = "6714f3f04f0f" down_revision = "7f0d1b5af8c7" diff --git a/warehouse/migrations/versions/68a00c174ba5_add_missing_indexes_for_foreign_keys.py b/warehouse/migrations/versions/68a00c174ba5_add_missing_indexes_for_foreign_keys.py index 29f03651dcf0..89f7c58d84e8 100644 --- a/warehouse/migrations/versions/68a00c174ba5_add_missing_indexes_for_foreign_keys.py +++ b/warehouse/migrations/versions/68a00c174ba5_add_missing_indexes_for_foreign_keys.py @@ -19,7 +19,6 @@ from alembic import op - revision = "68a00c174ba5" down_revision = "42e76a605cac" diff --git a/warehouse/migrations/versions/6a03266b2d_add_a_function_to_get_the_array_index.py b/warehouse/migrations/versions/6a03266b2d_add_a_function_to_get_the_array_index.py index 471171e21235..8efdc768f886 100644 --- a/warehouse/migrations/versions/6a03266b2d_add_a_function_to_get_the_array_index.py +++ b/warehouse/migrations/versions/6a03266b2d_add_a_function_to_get_the_array_index.py @@ -19,7 +19,6 @@ from alembic import op - revision = "6a03266b2d" down_revision = "3bc5176b880" diff --git a/warehouse/migrations/versions/6a6eb0a95603_drop_unused_indexes.py b/warehouse/migrations/versions/6a6eb0a95603_drop_unused_indexes.py index e37abbac96bb..2b93b35e2f23 100644 --- a/warehouse/migrations/versions/6a6eb0a95603_drop_unused_indexes.py +++ b/warehouse/migrations/versions/6a6eb0a95603_drop_unused_indexes.py @@ -19,7 +19,6 @@ from alembic import op - revision = "6a6eb0a95603" down_revision = "4e7d5154cb0c" diff --git a/warehouse/migrations/versions/6ff880c36cd9_add_a_path_column_to_store_the_location_.py b/warehouse/migrations/versions/6ff880c36cd9_add_a_path_column_to_store_the_location_.py index c46f8d60c375..131695427d35 100644 --- a/warehouse/migrations/versions/6ff880c36cd9_add_a_path_column_to_store_the_location_.py +++ b/warehouse/migrations/versions/6ff880c36cd9_add_a_path_column_to_store_the_location_.py @@ -17,9 +17,9 @@ Create Date: 2016-01-06 20:37:45.190833 """ -from alembic import op import sqlalchemy as sa +from alembic import op revision = "6ff880c36cd9" down_revision = "f392e419ea1b" diff --git a/warehouse/migrations/versions/7165e957cddc_create_table_for_warehouse_.py b/warehouse/migrations/versions/7165e957cddc_create_table_for_warehouse_.py index ca4fbb1b002f..2130369243d4 100644 --- a/warehouse/migrations/versions/7165e957cddc_create_table_for_warehouse_.py +++ b/warehouse/migrations/versions/7165e957cddc_create_table_for_warehouse_.py @@ -17,9 +17,9 @@ Create Date: 2018-02-17 18:42:18.209572 """ -from alembic import op import sqlalchemy as sa +from alembic import op revision = "7165e957cddc" down_revision = "1e2ccd34f539" diff --git a/warehouse/migrations/versions/7750037b351a_remove_useless_index.py b/warehouse/migrations/versions/7750037b351a_remove_useless_index.py index 1a30d5333d9a..437313e71277 100644 --- a/warehouse/migrations/versions/7750037b351a_remove_useless_index.py +++ b/warehouse/migrations/versions/7750037b351a_remove_useless_index.py @@ -19,7 +19,6 @@ from alembic import op - revision = "7750037b351a" down_revision = "f449e5bff5a5" diff --git a/warehouse/migrations/versions/7f0d1b5af8c7_add_tables_for_storing_ses_information.py b/warehouse/migrations/versions/7f0d1b5af8c7_add_tables_for_storing_ses_information.py index 9dada89e4430..c8aa4f75972e 100644 --- a/warehouse/migrations/versions/7f0d1b5af8c7_add_tables_for_storing_ses_information.py +++ b/warehouse/migrations/versions/7f0d1b5af8c7_add_tables_for_storing_ses_information.py @@ -17,8 +17,9 @@ Create Date: 2018-04-02 15:29:59.499569 """ -from alembic import op import sqlalchemy as sa + +from alembic import op from sqlalchemy.dialects import postgresql revision = "7f0d1b5af8c7" diff --git a/warehouse/migrations/versions/895279cc4490_cascade_deletes_for_ses_events.py b/warehouse/migrations/versions/895279cc4490_cascade_deletes_for_ses_events.py index faf417f3b2c7..96779ce50c4a 100644 --- a/warehouse/migrations/versions/895279cc4490_cascade_deletes_for_ses_events.py +++ b/warehouse/migrations/versions/895279cc4490_cascade_deletes_for_ses_events.py @@ -19,7 +19,6 @@ from alembic import op - revision = "895279cc4490" down_revision = "b00323b3efd8" diff --git a/warehouse/migrations/versions/8c8be2c0e69e_switch_to_a_uuid_based_primary_key_for_.py b/warehouse/migrations/versions/8c8be2c0e69e_switch_to_a_uuid_based_primary_key_for_.py index c374ec94f16e..751f33d38caa 100644 --- a/warehouse/migrations/versions/8c8be2c0e69e_switch_to_a_uuid_based_primary_key_for_.py +++ b/warehouse/migrations/versions/8c8be2c0e69e_switch_to_a_uuid_based_primary_key_for_.py @@ -23,7 +23,6 @@ from alembic import op from sqlalchemy.dialects import postgresql - revision = "8c8be2c0e69e" down_revision = "039f45e2dbf9" diff --git a/warehouse/migrations/versions/91508cc5c2_add_pep_426_normalize_index.py b/warehouse/migrations/versions/91508cc5c2_add_pep_426_normalize_index.py index c5a269c33d7e..53ef24cace13 100644 --- a/warehouse/migrations/versions/91508cc5c2_add_pep_426_normalize_index.py +++ b/warehouse/migrations/versions/91508cc5c2_add_pep_426_normalize_index.py @@ -19,7 +19,6 @@ from alembic import op - revision = "91508cc5c2" down_revision = "20f4dbe11e9" diff --git a/warehouse/migrations/versions/9177113533_add_a_column_to_specify_a_project_.py b/warehouse/migrations/versions/9177113533_add_a_column_to_specify_a_project_.py index 13fe45e78f60..2017385e8121 100644 --- a/warehouse/migrations/versions/9177113533_add_a_column_to_specify_a_project_.py +++ b/warehouse/migrations/versions/9177113533_add_a_column_to_specify_a_project_.py @@ -17,9 +17,9 @@ Create Date: 2015-09-04 21:06:59.950947 """ -from alembic import op import sqlalchemy as sa +from alembic import op revision = "9177113533" down_revision = "10cb17aea73" diff --git a/warehouse/migrations/versions/99291f0fe9c2_update_release_file_on_insert.py b/warehouse/migrations/versions/99291f0fe9c2_update_release_file_on_insert.py index 60d572ac95de..1764d38fb685 100644 --- a/warehouse/migrations/versions/99291f0fe9c2_update_release_file_on_insert.py +++ b/warehouse/migrations/versions/99291f0fe9c2_update_release_file_on_insert.py @@ -27,7 +27,6 @@ from alembic import op - revision = "99291f0fe9c2" down_revision = "e7b09b5c089d" diff --git a/warehouse/migrations/versions/a65114e48d6f_set_user_last_login_automatically_in_.py b/warehouse/migrations/versions/a65114e48d6f_set_user_last_login_automatically_in_.py index e736b0e94318..0f0131863047 100644 --- a/warehouse/migrations/versions/a65114e48d6f_set_user_last_login_automatically_in_.py +++ b/warehouse/migrations/versions/a65114e48d6f_set_user_last_login_automatically_in_.py @@ -17,9 +17,9 @@ Create Date: 2016-06-11 00:28:39.176496 """ -from alembic import op import sqlalchemy as sa +from alembic import op revision = "a65114e48d6f" down_revision = "104b4c56862b" diff --git a/warehouse/migrations/versions/b00323b3efd8_uploaded_via_field_for_release_.py b/warehouse/migrations/versions/b00323b3efd8_uploaded_via_field_for_release_.py index 59cf13042264..968b97036b51 100644 --- a/warehouse/migrations/versions/b00323b3efd8_uploaded_via_field_for_release_.py +++ b/warehouse/migrations/versions/b00323b3efd8_uploaded_via_field_for_release_.py @@ -17,9 +17,9 @@ Create Date: 2018-07-25 17:29:01.995083 """ -from alembic import op import sqlalchemy as sa +from alembic import op revision = "b00323b3efd8" down_revision = "f2a453c96ded" diff --git a/warehouse/migrations/versions/b6a20b9c888d_add_a_table_to_hold_blacklisted_projects.py b/warehouse/migrations/versions/b6a20b9c888d_add_a_table_to_hold_blacklisted_projects.py index e0d22af1e252..f57fa8b8a28c 100644 --- a/warehouse/migrations/versions/b6a20b9c888d_add_a_table_to_hold_blacklisted_projects.py +++ b/warehouse/migrations/versions/b6a20b9c888d_add_a_table_to_hold_blacklisted_projects.py @@ -17,10 +17,10 @@ Create Date: 2017-09-15 16:24:03.201478 """ -from alembic import op import sqlalchemy as sa -from sqlalchemy.dialects import postgresql +from alembic import op +from sqlalchemy.dialects import postgresql revision = "b6a20b9c888d" down_revision = "5b3f9e687d94" diff --git a/warehouse/migrations/versions/b75709859292_add_ondelete_cascade_for_description_.py b/warehouse/migrations/versions/b75709859292_add_ondelete_cascade_for_description_.py index 560b530d8de6..e4eafa3d7063 100644 --- a/warehouse/migrations/versions/b75709859292_add_ondelete_cascade_for_description_.py +++ b/warehouse/migrations/versions/b75709859292_add_ondelete_cascade_for_description_.py @@ -19,7 +19,6 @@ from alembic import op - revision = "b75709859292" down_revision = "7165e957cddc" diff --git a/warehouse/migrations/versions/b8fda0d7fbb5_updated_to_newer_alembic_mechanisms.py b/warehouse/migrations/versions/b8fda0d7fbb5_updated_to_newer_alembic_mechanisms.py index 1bf64e4e2c0a..0675b089ad5c 100644 --- a/warehouse/migrations/versions/b8fda0d7fbb5_updated_to_newer_alembic_mechanisms.py +++ b/warehouse/migrations/versions/b8fda0d7fbb5_updated_to_newer_alembic_mechanisms.py @@ -19,7 +19,6 @@ from alembic import op - revision = "b8fda0d7fbb5" down_revision = "99291f0fe9c2" diff --git a/warehouse/migrations/versions/be4cf6b58557_add_requires_python_to_release_files.py b/warehouse/migrations/versions/be4cf6b58557_add_requires_python_to_release_files.py index eb473bc08739..e97364e3b3af 100644 --- a/warehouse/migrations/versions/be4cf6b58557_add_requires_python_to_release_files.py +++ b/warehouse/migrations/versions/be4cf6b58557_add_requires_python_to_release_files.py @@ -17,9 +17,9 @@ Create Date: 2016-09-15 04:12:53.430363 """ -from alembic import op import sqlalchemy as sa +from alembic import op revision = "be4cf6b58557" down_revision = "3d2b8a42219a" diff --git a/warehouse/migrations/versions/bf73e785eed9_add_notify_column_to_adminflag.py b/warehouse/migrations/versions/bf73e785eed9_add_notify_column_to_adminflag.py index 250fa7ad3ddf..496561869f8e 100644 --- a/warehouse/migrations/versions/bf73e785eed9_add_notify_column_to_adminflag.py +++ b/warehouse/migrations/versions/bf73e785eed9_add_notify_column_to_adminflag.py @@ -17,9 +17,10 @@ Create Date: 2018-03-23 21:20:05.834821 """ -from alembic import op import sqlalchemy as sa +from alembic import op + revision = "bf73e785eed9" down_revision = "5dda74213989" diff --git a/warehouse/migrations/versions/c0682028c857_cascade_role_deletion.py b/warehouse/migrations/versions/c0682028c857_cascade_role_deletion.py index f011a811fbbf..de282a5615cc 100644 --- a/warehouse/migrations/versions/c0682028c857_cascade_role_deletion.py +++ b/warehouse/migrations/versions/c0682028c857_cascade_role_deletion.py @@ -19,7 +19,6 @@ from alembic import op - revision = "c0682028c857" down_revision = "1fdf5dc6bbf3" diff --git a/warehouse/migrations/versions/d8301a1bf519_add_a_column_for_sha256_digests.py b/warehouse/migrations/versions/d8301a1bf519_add_a_column_for_sha256_digests.py index e6e620852587..c8834044148b 100644 --- a/warehouse/migrations/versions/d8301a1bf519_add_a_column_for_sha256_digests.py +++ b/warehouse/migrations/versions/d8301a1bf519_add_a_column_for_sha256_digests.py @@ -22,7 +22,6 @@ from alembic import op - revision = "d8301a1bf519" down_revision = "477bc785c999" diff --git a/warehouse/migrations/versions/e0ca60b6a30b_add_deprecated_column_to_classifiers.py b/warehouse/migrations/versions/e0ca60b6a30b_add_deprecated_column_to_classifiers.py index 801fcb6c929a..a25e8379348f 100644 --- a/warehouse/migrations/versions/e0ca60b6a30b_add_deprecated_column_to_classifiers.py +++ b/warehouse/migrations/versions/e0ca60b6a30b_add_deprecated_column_to_classifiers.py @@ -17,9 +17,9 @@ Create Date: 2018-04-18 23:24:13.009357 """ -from alembic import op import sqlalchemy as sa +from alembic import op revision = "e0ca60b6a30b" down_revision = "6714f3f04f0f" diff --git a/warehouse/migrations/versions/e612a92c1017_add_uploader_field_to_release.py b/warehouse/migrations/versions/e612a92c1017_add_uploader_field_to_release.py index 3ef326d54fc2..25b68955b928 100644 --- a/warehouse/migrations/versions/e612a92c1017_add_uploader_field_to_release.py +++ b/warehouse/migrations/versions/e612a92c1017_add_uploader_field_to_release.py @@ -17,12 +17,11 @@ Create Date: 2018-11-06 16:22:01.484362 """ -from alembic import op import sqlalchemy as sa +from alembic import op from sqlalchemy.dialects import postgresql - revision = "e612a92c1017" down_revision = "5538f2d929dd" diff --git a/warehouse/migrations/versions/e7b09b5c089d_add_pep440_is_prerelease.py b/warehouse/migrations/versions/e7b09b5c089d_add_pep440_is_prerelease.py index 3d88e686a33f..4be9d763b0f1 100644 --- a/warehouse/migrations/versions/e7b09b5c089d_add_pep440_is_prerelease.py +++ b/warehouse/migrations/versions/e7b09b5c089d_add_pep440_is_prerelease.py @@ -19,7 +19,6 @@ from alembic import op - revision = "e7b09b5c089d" down_revision = "be4cf6b58557" diff --git a/warehouse/migrations/versions/e82c3a017d60_remove_unused_columns.py b/warehouse/migrations/versions/e82c3a017d60_remove_unused_columns.py index 683cdac2b48e..684c3f47e824 100644 --- a/warehouse/migrations/versions/e82c3a017d60_remove_unused_columns.py +++ b/warehouse/migrations/versions/e82c3a017d60_remove_unused_columns.py @@ -19,7 +19,6 @@ from alembic import op - revision = "e82c3a017d60" down_revision = "62f6becc7653" diff --git a/warehouse/migrations/versions/ee5b8f66a223_migrate_projects_and_releases_to_.py b/warehouse/migrations/versions/ee5b8f66a223_migrate_projects_and_releases_to_.py index 37df58cc9ebc..a45cc7491728 100644 --- a/warehouse/migrations/versions/ee5b8f66a223_migrate_projects_and_releases_to_.py +++ b/warehouse/migrations/versions/ee5b8f66a223_migrate_projects_and_releases_to_.py @@ -17,8 +17,9 @@ Create Date: 2018-10-27 16:31:38.859484 """ -from alembic import op import sqlalchemy as sa + +from alembic import op from sqlalchemy.dialects import postgresql revision = "ee5b8f66a223" diff --git a/warehouse/migrations/versions/eeb23d9b4d00_add_squats_table.py b/warehouse/migrations/versions/eeb23d9b4d00_add_squats_table.py index 0870b4240b35..cd69fcd0eed3 100644 --- a/warehouse/migrations/versions/eeb23d9b4d00_add_squats_table.py +++ b/warehouse/migrations/versions/eeb23d9b4d00_add_squats_table.py @@ -17,9 +17,9 @@ Create Date: 2018-11-03 06:05:42.158355 """ -from alembic import op import sqlalchemy as sa +from alembic import op revision = "eeb23d9b4d00" down_revision = "56e9e630c748" diff --git a/warehouse/migrations/versions/f2a453c96ded_remove_no_longer_needed_tables.py b/warehouse/migrations/versions/f2a453c96ded_remove_no_longer_needed_tables.py index 293cc523a327..27cfd6fdddf1 100644 --- a/warehouse/migrations/versions/f2a453c96ded_remove_no_longer_needed_tables.py +++ b/warehouse/migrations/versions/f2a453c96ded_remove_no_longer_needed_tables.py @@ -19,7 +19,6 @@ from alembic import op - revision = "f2a453c96ded" down_revision = "e0ca60b6a30b" diff --git a/warehouse/migrations/versions/f392e419ea1b_mandate_sha256_hashes_for_all_files.py b/warehouse/migrations/versions/f392e419ea1b_mandate_sha256_hashes_for_all_files.py index 257fc1a66312..1fb00a552ee1 100644 --- a/warehouse/migrations/versions/f392e419ea1b_mandate_sha256_hashes_for_all_files.py +++ b/warehouse/migrations/versions/f392e419ea1b_mandate_sha256_hashes_for_all_files.py @@ -19,7 +19,6 @@ from alembic import op - revision = "f392e419ea1b" down_revision = "d8301a1bf519" diff --git a/warehouse/migrations/versions/f404a67e0370_disable_legacy_file_types_unless_a_.py b/warehouse/migrations/versions/f404a67e0370_disable_legacy_file_types_unless_a_.py index 4b88987f174b..f19af427db6b 100644 --- a/warehouse/migrations/versions/f404a67e0370_disable_legacy_file_types_unless_a_.py +++ b/warehouse/migrations/versions/f404a67e0370_disable_legacy_file_types_unless_a_.py @@ -19,7 +19,6 @@ from alembic import op - revision = "f404a67e0370" down_revision = "b8fda0d7fbb5" diff --git a/warehouse/migrations/versions/f449e5bff5a5_disallow_multiple_sdists_for_a_release.py b/warehouse/migrations/versions/f449e5bff5a5_disallow_multiple_sdists_for_a_release.py index 6e18d9d8fff0..b1eb11ffdf1f 100644 --- a/warehouse/migrations/versions/f449e5bff5a5_disallow_multiple_sdists_for_a_release.py +++ b/warehouse/migrations/versions/f449e5bff5a5_disallow_multiple_sdists_for_a_release.py @@ -17,9 +17,9 @@ Create Date: 2016-12-17 17:10:31.252165 """ -from alembic import op import sqlalchemy as sa +from alembic import op revision = "f449e5bff5a5" down_revision = "f404a67e0370" diff --git a/warehouse/migrations/versions/f46672a776f1_make_file_path_mandatory.py b/warehouse/migrations/versions/f46672a776f1_make_file_path_mandatory.py index 596235bd76f6..1ac3bfab6c8e 100644 --- a/warehouse/migrations/versions/f46672a776f1_make_file_path_mandatory.py +++ b/warehouse/migrations/versions/f46672a776f1_make_file_path_mandatory.py @@ -19,7 +19,6 @@ from alembic import op - revision = "f46672a776f1" down_revision = "6ff880c36cd9" diff --git a/warehouse/migrations/versions/f7577b6938c1_add_canonical_version_column.py b/warehouse/migrations/versions/f7577b6938c1_add_canonical_version_column.py index b313f72be178..f8c1c0d32dab 100644 --- a/warehouse/migrations/versions/f7577b6938c1_add_canonical_version_column.py +++ b/warehouse/migrations/versions/f7577b6938c1_add_canonical_version_column.py @@ -17,9 +17,9 @@ Create Date: 2018-02-28 15:54:48.867703 """ -from alembic import op import sqlalchemy as sa +from alembic import op revision = "f7577b6938c1" down_revision = "b75709859292" diff --git a/warehouse/migrations/versions/fb3278418206_ensure_file_md5_blake2_256__digest_are_.py b/warehouse/migrations/versions/fb3278418206_ensure_file_md5_blake2_256__digest_are_.py index 79a967eaac49..c64f82eaef77 100644 --- a/warehouse/migrations/versions/fb3278418206_ensure_file_md5_blake2_256__digest_are_.py +++ b/warehouse/migrations/versions/fb3278418206_ensure_file_md5_blake2_256__digest_are_.py @@ -22,7 +22,6 @@ from alembic import op - revision = "fb3278418206" down_revision = "0977b97fce94" diff --git a/warehouse/packaging/models.py b/warehouse/packaging/models.py index 527b18f99c67..1d1de7ced6bc 100644 --- a/warehouse/packaging/models.py +++ b/warehouse/packaging/models.py @@ -21,25 +21,27 @@ from pyramid.security import Allow from pyramid.threadlocal import get_current_request from sqlalchemy import ( + Boolean, CheckConstraint, Column, + DateTime, Enum, + Float, ForeignKey, Index, - Boolean, - DateTime, Integer, - Float, Table, Text, + func, + orm, + sql, ) -from sqlalchemy import func, orm, sql from sqlalchemy.dialects.postgresql import UUID -from sqlalchemy.orm import validates -from sqlalchemy.orm.exc import MultipleResultsFound, NoResultFound from sqlalchemy.ext.associationproxy import association_proxy from sqlalchemy.ext.declarative import declared_attr from sqlalchemy.ext.hybrid import hybrid_property +from sqlalchemy.orm import validates +from sqlalchemy.orm.exc import MultipleResultsFound, NoResultFound from warehouse import db from warehouse.accounts.models import User diff --git a/warehouse/packaging/search.py b/warehouse/packaging/search.py index c72437bec7a8..b66933246ac7 100644 --- a/warehouse/packaging/search.py +++ b/warehouse/packaging/search.py @@ -12,11 +12,10 @@ import packaging.version -from elasticsearch_dsl import Document, Text, Keyword, analyzer, Date +from elasticsearch_dsl import Date, Document, Keyword, Text, analyzer from warehouse.search.utils import doc_type - EmailAnalyzer = analyzer( "email", tokenizer="uax_url_email", diff --git a/warehouse/packaging/services.py b/warehouse/packaging/services.py index 8d77e46e868a..a7b724258297 100644 --- a/warehouse/packaging/services.py +++ b/warehouse/packaging/services.py @@ -18,7 +18,7 @@ from zope.interface import implementer -from warehouse.packaging.interfaces import IFileStorage, IDocsStorage +from warehouse.packaging.interfaces import IDocsStorage, IFileStorage class InsecureStorageWarning(UserWarning): diff --git a/warehouse/packaging/views.py b/warehouse/packaging/views.py index 69b325ef5f2d..c7471c0c156f 100644 --- a/warehouse/packaging/views.py +++ b/warehouse/packaging/views.py @@ -14,10 +14,10 @@ from pyramid.view import view_config from sqlalchemy.orm.exc import NoResultFound -from warehouse.utils import readme from warehouse.accounts.models import User from warehouse.cache.origin import origin_cache from warehouse.packaging.models import Project, Release, Role +from warehouse.utils import readme @view_config( diff --git a/warehouse/policy.py b/warehouse/policy.py index 1114248c42ca..4093d6676bd8 100644 --- a/warehouse/policy.py +++ b/warehouse/policy.py @@ -18,7 +18,6 @@ import warehouse - DEFAULT_POLICY_DIRECTORY = os.path.abspath( os.path.join(os.path.dirname(os.path.dirname(warehouse.__file__)), "policies") ) diff --git a/warehouse/redirects.py b/warehouse/redirects.py index f18c3a7f2d3a..a8df8b90cf82 100644 --- a/warehouse/redirects.py +++ b/warehouse/redirects.py @@ -10,7 +10,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from pyramid.httpexceptions import HTTPMovedPermanently, HTTPBadRequest +from pyramid.httpexceptions import HTTPBadRequest, HTTPMovedPermanently def redirect_view_factory(target, redirect=HTTPMovedPermanently, **kw): diff --git a/warehouse/sanity.py b/warehouse/sanity.py index 5e206c20cc4c..f461bb8da985 100644 --- a/warehouse/sanity.py +++ b/warehouse/sanity.py @@ -13,7 +13,7 @@ import urllib.parse from pyramid.config import PHASE3_CONFIG -from pyramid.httpexceptions import HTTPException, HTTPBadRequest +from pyramid.httpexceptions import HTTPBadRequest, HTTPException from pyramid.interfaces import ITweens diff --git a/warehouse/search/tasks.py b/warehouse/search/tasks.py index 959172ade40e..5480f2d77d83 100644 --- a/warehouse/search/tasks.py +++ b/warehouse/search/tasks.py @@ -11,21 +11,22 @@ # limitations under the License. import binascii -import urllib import os +import urllib + +import certifi +import elasticsearch +import redis from elasticsearch.helpers import parallel_bulk from elasticsearch_dsl import serializer from sqlalchemy import func from sqlalchemy.orm import aliased -import certifi -import elasticsearch -import redis +from warehouse import tasks from warehouse.packaging.models import Classifier, Project, Release, release_classifiers from warehouse.packaging.search import Project as ProjectDocument from warehouse.search.utils import get_index -from warehouse import tasks from warehouse.utils.db import windowed_query diff --git a/warehouse/sitemap/views.py b/warehouse/sitemap/views.py index 2c06a0f6ea82..3674361971b1 100644 --- a/warehouse/sitemap/views.py +++ b/warehouse/sitemap/views.py @@ -17,12 +17,11 @@ from sqlalchemy import func from warehouse.accounts.models import User -from warehouse.cache.origin import origin_cache from warehouse.cache.http import cache_control +from warehouse.cache.origin import origin_cache from warehouse.packaging.models import Project from warehouse.xml import XML_CSP - SITEMAP_MAXSIZE = 50000 diff --git a/warehouse/static.py b/warehouse/static.py index a5f656aefb28..a1c3d4e141da 100644 --- a/warehouse/static.py +++ b/warehouse/static.py @@ -16,7 +16,6 @@ from pyramid.path import AssetResolver from whitenoise import WhiteNoise - resolver = AssetResolver() diff --git a/warehouse/tasks.py b/warehouse/tasks.py index b4287c47c0e7..f11c480e074b 100644 --- a/warehouse/tasks.py +++ b/warehouse/tasks.py @@ -13,15 +13,8 @@ import functools import urllib.parse -import celery.app.backends - -# We need to trick Celery into supporting rediss:// URLs which is how redis-py -# signals that you should use Redis with TLS. -celery.app.backends.BACKEND_ALIASES[ - "rediss" -] = "warehouse.tasks:TLSRedisBackend" # noqa - import celery +import celery.app.backends import celery.backends.redis import pyramid.scripting import pyramid_retry @@ -32,6 +25,12 @@ from warehouse.config import Environment +# We need to trick Celery into supporting rediss:// URLs which is how redis-py +# signals that you should use Redis with TLS. +celery.app.backends.BACKEND_ALIASES[ + "rediss" +] = "warehouse.tasks:TLSRedisBackend" # noqa + # We need to register that the sqs:// url scheme uses a netloc urllib.parse.uses_netloc.append("sqs") diff --git a/warehouse/utils/compression.py b/warehouse/utils/compression.py index b347da151aad..6d7e6e6cc9bb 100644 --- a/warehouse/utils/compression.py +++ b/warehouse/utils/compression.py @@ -15,7 +15,6 @@ from collections.abc import Sequence - ENCODINGS = ["identity", "gzip"] DEFAULT_ENCODING = "identity" BUFFER_MAX = 1 * 1024 * 1024 # We'll buffer up to 1MB diff --git a/warehouse/utils/crypto.py b/warehouse/utils/crypto.py index dfc7df6b1000..caa5ed8f7f2c 100644 --- a/warehouse/utils/crypto.py +++ b/warehouse/utils/crypto.py @@ -23,7 +23,6 @@ URLSafeTimedSerializer as _URLSafeTimedSerializer, ) - __all__ = [ "BadData", "BadSignature", diff --git a/warehouse/utils/http.py b/warehouse/utils/http.py index fbc7ac4f56ce..f19e743e0277 100644 --- a/warehouse/utils/http.py +++ b/warehouse/utils/http.py @@ -14,7 +14,7 @@ from urllib.parse import urlparse -from rfc3986 import uri_reference, validators, exceptions +from rfc3986 import exceptions, uri_reference, validators # FROM https://github.com/django/django/blob/ diff --git a/warehouse/utils/project.py b/warehouse/utils/project.py index bdd9babe4820..c4780d92d716 100644 --- a/warehouse/utils/project.py +++ b/warehouse/utils/project.py @@ -13,9 +13,9 @@ from packaging.utils import canonicalize_name from pyramid.httpexceptions import HTTPSeeOther -from warehouse.tasks import task from warehouse.packaging.interfaces import IDocsStorage from warehouse.packaging.models import JournalEntry +from warehouse.tasks import task @task(bind=True, ignore_result=True, acks_late=True) diff --git a/warehouse/utils/readme.py b/warehouse/utils/readme.py index 5b2df3001f94..cef58fb193f9 100644 --- a/warehouse/utils/readme.py +++ b/warehouse/utils/readme.py @@ -19,7 +19,6 @@ import readme_renderer.rst import readme_renderer.txt - _RENDERERS = { None: readme_renderer.rst, # Default if description_content_type is None "": readme_renderer.rst, # Default if description_content_type is None diff --git a/warehouse/utils/row_counter.py b/warehouse/utils/row_counter.py index a59d68d70400..b77f77691b2a 100644 --- a/warehouse/utils/row_counter.py +++ b/warehouse/utils/row_counter.py @@ -10,8 +10,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from sqlalchemy import BigInteger, Column, Text -from sqlalchemy import sql +from sqlalchemy import BigInteger, Column, Text, sql from warehouse import db diff --git a/warehouse/utils/sns.py b/warehouse/utils/sns.py index e0f43cca53d7..95e61fa40736 100644 --- a/warehouse/utils/sns.py +++ b/warehouse/utils/sns.py @@ -23,7 +23,6 @@ from cryptography.hazmat.primitives.asymmetric.padding import PKCS1v15 from cryptography.hazmat.primitives.hashes import SHA1 - _signing_url_host_re = re.compile(r"^sns\.[a-zA-Z0-9\-]{3,}\.amazonaws\.com(\.cn)?$") diff --git a/warehouse/views.py b/warehouse/views.py index 2ae52cee3bba..786b0ec66fc6 100644 --- a/warehouse/views.py +++ b/warehouse/views.py @@ -15,41 +15,40 @@ import elasticsearch +from elasticsearch_dsl import Q +from pyramid.exceptions import PredicateMismatch from pyramid.httpexceptions import ( + HTTPBadRequest, HTTPException, - HTTPSeeOther, HTTPMovedPermanently, HTTPNotFound, - HTTPBadRequest, + HTTPSeeOther, HTTPServiceUnavailable, exception_response, ) -from pyramid.exceptions import PredicateMismatch from pyramid.renderers import render_to_response from pyramid.response import Response from pyramid.view import ( - notfound_view_config, - forbidden_view_config, exception_view_config, + forbidden_view_config, + notfound_view_config, view_config, ) -from elasticsearch_dsl import Q from sqlalchemy import func from sqlalchemy.orm import aliased, joinedload from sqlalchemy.sql import exists -from warehouse.db import DatabaseNotAvailable from warehouse.accounts import REDIRECT_FIELD_NAME from warehouse.accounts.models import User -from warehouse.cache.origin import origin_cache from warehouse.cache.http import add_vary, cache_control +from warehouse.cache.origin import origin_cache from warehouse.classifiers.models import Classifier +from warehouse.db import DatabaseNotAvailable from warehouse.metrics import IMetricsService -from warehouse.packaging.models import Project, Release, File, release_classifiers +from warehouse.packaging.models import File, Project, Release, release_classifiers from warehouse.search.queries import SEARCH_BOOSTS, SEARCH_FIELDS, SEARCH_FILTER_ORDER -from warehouse.utils.row_counter import RowCount from warehouse.utils.paginate import ElasticsearchPage, paginate_url_factory - +from warehouse.utils.row_counter import RowCount # 403, 404, 410, 500,