diff --git a/api/shared/repo/mixins.py b/api/shared/repo/mixins.py index db3afd7763..7a9388dab1 100644 --- a/api/shared/repo/mixins.py +++ b/api/shared/repo/mixins.py @@ -19,7 +19,7 @@ class RepositoryViewSetMixin( OwnerPropertyMixin, viewsets.GenericViewSet, ): - lookup_value_regex = "[\w\.@\:\-~]+" + lookup_value_regex = r"[\w\.@\:\-~]+" lookup_field = "repo_name" accessors = RepoAccessors() diff --git a/codecov_auth/views/base.py b/codecov_auth/views/base.py index 4d494efaad..254189eed0 100644 --- a/codecov_auth/views/base.py +++ b/codecov_auth/views/base.py @@ -61,7 +61,7 @@ class StateMixin(object): def __init__(self, *args, **kwargs): self.redis = get_redis_connection() - return super().__init__(*args, **kwargs) + super().__init__(*args, **kwargs) def _session_key(self) -> str: return f"{self.service}_oauth_state" diff --git a/core/migrations/0026_auto_20230605_1134.py b/core/migrations/0026_auto_20230605_1134.py index 516fa48394..83a199172f 100644 --- a/core/migrations/0026_auto_20230605_1134.py +++ b/core/migrations/0026_auto_20230605_1134.py @@ -11,7 +11,7 @@ class Migration(migrations.Migration): operations = [ migrations.RunSQL( """ - ALTER TYPE notifications ADD VALUE IF NOT exists 'codecov_slack_app'; + ALTER TYPE notifications ADD VALUE IF NOT exists 'codecov_slack_app'; """ ), ] diff --git a/graphql_api/dataloader/commit.py b/graphql_api/dataloader/commit.py index 29df28ed62..335a1b1f31 100644 --- a/graphql_api/dataloader/commit.py +++ b/graphql_api/dataloader/commit.py @@ -13,7 +13,7 @@ def key(cls, commit): def __init__(self, info, repository_id, *args, **kwargs): self.repository_id = repository_id - return super().__init__(info, *args, **kwargs) + super().__init__(info, *args, **kwargs) def batch_queryset(self, keys): # We don't select the `report` or `files_array` columns here b/c then can be diff --git a/graphql_api/dataloader/comparison.py b/graphql_api/dataloader/comparison.py index 07e9dcc8a6..7e607e0929 100644 --- a/graphql_api/dataloader/comparison.py +++ b/graphql_api/dataloader/comparison.py @@ -35,7 +35,7 @@ def key(cls, commit_comparison): def __init__(self, info, repository_id, *args, **kwargs): self.repository_id = repository_id - return super().__init__(info, *args, **kwargs) + super().__init__(info, *args, **kwargs) def batch_queryset(self, keys): return CommitComparisonService.fetch_precomputed(self.repository_id, keys) diff --git a/graphql_api/tests/test_branch.py b/graphql_api/tests/test_branch.py index cd7aacb4fb..1e157db043 100644 --- a/graphql_api/tests/test_branch.py +++ b/graphql_api/tests/test_branch.py @@ -46,7 +46,7 @@ percentCovered ... on PathContentFile { isCriticalFile - } + } } } ... on MissingHeadReport { diff --git a/graphs/tests/test_badge_handler.py b/graphs/tests/test_badge_handler.py index f8fa5f0761..3f8026861b 100644 --- a/graphs/tests/test_badge_handler.py +++ b/graphs/tests/test_badge_handler.py @@ -914,7 +914,7 @@ def test_flag_badge(self, full_report_mock): data={"flag": "unittests"}, ) - expected_badge = """ + expected_badge = """ diff --git a/legacy_migrations/migrations/0002_yaml_history_table.py b/legacy_migrations/migrations/0002_yaml_history_table.py index 1de1cc7059..2157b57cfd 100644 --- a/legacy_migrations/migrations/0002_yaml_history_table.py +++ b/legacy_migrations/migrations/0002_yaml_history_table.py @@ -38,7 +38,7 @@ class Migration(migrations.Migration): migrations.RunSQL( sql=""" create index if not exists yaml_history_ownerid_timestamp - on yaml_history (ownerid, timestamp); + on yaml_history (ownerid, timestamp); """, reverse_sql="drop index if exists yaml_history_ownerid_timestamp;", ), diff --git a/legacy_migrations/migrations/0003_auto_20230120_1837.py b/legacy_migrations/migrations/0003_auto_20230120_1837.py index 6213a86f26..5e492a2d5d 100644 --- a/legacy_migrations/migrations/0003_auto_20230120_1837.py +++ b/legacy_migrations/migrations/0003_auto_20230120_1837.py @@ -27,7 +27,7 @@ class Migration(migrations.Migration): migrations.RunSQL( """ drop trigger repos_before_update on repos; - + create trigger repos_before_update before update on repos for each row when (new.name is not null and new.name is distinct from old.name) diff --git a/legacy_migrations/migrations/legacy_sql/main/functions/aggregates.py b/legacy_migrations/migrations/legacy_sql/main/functions/aggregates.py index 85354b1282..9422991852 100644 --- a/legacy_migrations/migrations/legacy_sql/main/functions/aggregates.py +++ b/legacy_migrations/migrations/legacy_sql/main/functions/aggregates.py @@ -66,6 +66,6 @@ def run_sql(schema_editor): SFUNC = _agg_report_totals, STYPE = text[] ); - + """ ) diff --git a/legacy_migrations/migrations/legacy_sql/main/functions/get_customer.py b/legacy_migrations/migrations/legacy_sql/main/functions/get_customer.py index 61e55a0fcf..4eeca2ede2 100644 --- a/legacy_migrations/migrations/legacy_sql/main/functions/get_customer.py +++ b/legacy_migrations/migrations/legacy_sql/main/functions/get_customer.py @@ -85,7 +85,7 @@ def run_sql(schema_editor): begin select o.service, o.service_id into _service, _service_id from owners o where o.ownerid = $1; - + if _service = 'gitlab' then select get_gitlab_repos_activated($1, _service_id) into _repos_activated; else diff --git a/legacy_migrations/migrations/legacy_sql/main/functions/get_ownerid.py b/legacy_migrations/migrations/legacy_sql/main/functions/get_ownerid.py index fdf0fc13aa..869f59cec0 100644 --- a/legacy_migrations/migrations/legacy_sql/main/functions/get_ownerid.py +++ b/legacy_migrations/migrations/legacy_sql/main/functions/get_ownerid.py @@ -47,7 +47,7 @@ def run_sql(schema_editor): create or replace function get_owner(service, citext) returns jsonb as $$ with data as ( - select service_id, service, ownerid::text, username, avatar_url, + select service_id, service, ownerid::text, username, avatar_url, updatestamp, plan, name, integration_id, free, plan_activated_users, plan_auto_activate, plan_user_count from owners diff --git a/legacy_migrations/migrations/legacy_sql/main/functions/get_user.py b/legacy_migrations/migrations/legacy_sql/main/functions/get_user.py index 95103add4c..abdcba6bc1 100644 --- a/legacy_migrations/migrations/legacy_sql/main/functions/get_user.py +++ b/legacy_migrations/migrations/legacy_sql/main/functions/get_user.py @@ -21,7 +21,7 @@ def run_sql(schema_editor): create or replace function get_users(int[]) returns jsonb as $$ with data as ( - select service, service_id::text, ownerid::text, username, name, email, avatar_url + select service, service_id::text, ownerid::text, username, name, email, avatar_url from owners where array[ownerid] <@ $1 limit array_length($1, 1) diff --git a/legacy_migrations/migrations/legacy_sql/main/functions/refresh_repos.py b/legacy_migrations/migrations/legacy_sql/main/functions/refresh_repos.py index 1037f5ba1e..42105e8d38 100644 --- a/legacy_migrations/migrations/legacy_sql/main/functions/refresh_repos.py +++ b/legacy_migrations/migrations/legacy_sql/main/functions/refresh_repos.py @@ -20,12 +20,12 @@ def run_sql(schema_editor): if not found then insert into owners (service, service_id, username, name, email, avatar_url, parent_service_id) - values ($1, - (_team.d->>'id')::text, - (_team.d->>'username')::citext, - (_team.d->>'name')::text, - (_team.d->>'email')::text, - (_team.d->>'avatar_url')::text, + values ($1, + (_team.d->>'id')::text, + (_team.d->>'username')::citext, + (_team.d->>'name')::text, + (_team.d->>'email')::text, + (_team.d->>'avatar_url')::text, (_team.d->>'parent_id')::text ) returning ownerid into _ownerid; diff --git a/legacy_migrations/migrations/legacy_sql/main/tables/branches.py b/legacy_migrations/migrations/legacy_sql/main/tables/branches.py index 26a3849506..e34e535f63 100644 --- a/legacy_migrations/migrations/legacy_sql/main/tables/branches.py +++ b/legacy_migrations/migrations/legacy_sql/main/tables/branches.py @@ -1,6 +1,6 @@ def run_sql(schema_editor): schema_editor.execute( - """ + """ create table branches( repoid int references repos on delete cascade not null, updatestamp timestamptz not null, diff --git a/legacy_migrations/migrations/legacy_sql/main/tables/owners.py b/legacy_migrations/migrations/legacy_sql/main/tables/owners.py index 2c3fa7b6e3..346e65bb92 100644 --- a/legacy_migrations/migrations/legacy_sql/main/tables/owners.py +++ b/legacy_migrations/migrations/legacy_sql/main/tables/owners.py @@ -1,6 +1,6 @@ def run_sql(schema_editor): schema_editor.execute( - """ + """ create table owners( ownerid serial primary key, service service not null, diff --git a/legacy_migrations/migrations/legacy_sql/main/tables/repos.py b/legacy_migrations/migrations/legacy_sql/main/tables/repos.py index af83a9f52c..2623af5035 100644 --- a/legacy_migrations/migrations/legacy_sql/main/tables/repos.py +++ b/legacy_migrations/migrations/legacy_sql/main/tables/repos.py @@ -1,6 +1,6 @@ def run_sql(schema_editor): schema_editor.execute( - """ + """ create table repos( repoid serial primary key, ownerid int references owners on delete cascade not null, diff --git a/legacy_migrations/migrations/legacy_sql/main/tables/sessions.py b/legacy_migrations/migrations/legacy_sql/main/tables/sessions.py index 9c17b22e6d..8cccb99874 100644 --- a/legacy_migrations/migrations/legacy_sql/main/tables/sessions.py +++ b/legacy_migrations/migrations/legacy_sql/main/tables/sessions.py @@ -1,6 +1,6 @@ def run_sql(schema_editor): schema_editor.execute( - """ + """ create table sessions( sessionid serial primary key, token uuid unique default uuid_generate_v4() not null, diff --git a/legacy_migrations/migrations/legacy_sql/main/tables/users.py b/legacy_migrations/migrations/legacy_sql/main/tables/users.py index 7c05288031..2fd0f0d032 100644 --- a/legacy_migrations/migrations/legacy_sql/main/tables/users.py +++ b/legacy_migrations/migrations/legacy_sql/main/tables/users.py @@ -1,6 +1,6 @@ def run_sql(schema_editor): schema_editor.execute( - """ + """ CREATE TABLE IF NOT EXISTS "users" ( "id" bigint NOT NULL PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, "external_id" uuid NOT NULL UNIQUE, diff --git a/legacy_migrations/migrations/legacy_sql/main/triggers/pulls.py b/legacy_migrations/migrations/legacy_sql/main/triggers/pulls.py index 39c0e8afaf..00cc26a17c 100644 --- a/legacy_migrations/migrations/legacy_sql/main/triggers/pulls.py +++ b/legacy_migrations/migrations/legacy_sql/main/triggers/pulls.py @@ -1,6 +1,6 @@ def run_sql(schema_editor): schema_editor.execute( - """ + """ create or replace function pulls_drop_flare() returns trigger as $$ begin new.flare = null; diff --git a/legacy_migrations/migrations/legacy_sql/upgrades/v442.py b/legacy_migrations/migrations/legacy_sql/upgrades/v442.py index 3bad7a5192..7befcd0535 100644 --- a/legacy_migrations/migrations/legacy_sql/upgrades/v442.py +++ b/legacy_migrations/migrations/legacy_sql/upgrades/v442.py @@ -11,7 +11,7 @@ def run_sql(schema_editor): -- get_ownerid.sql create or replace function get_owner(service, citext) returns jsonb as $$ with data as ( - select service_id, service, ownerid::text, username, avatar_url, + select service_id, service, ownerid::text, username, avatar_url, updatestamp, plan, name, integration_id, free, plan_activated_users, plan_auto_activate, plan_user_count from owners @@ -60,7 +60,7 @@ def run_sql(schema_editor): -- get_user.sql create or replace function get_users(int[]) returns jsonb as $$ with data as ( - select service, service_id::text, ownerid::text, username, name, email, avatar_url + select service, service_id::text, ownerid::text, username, name, email, avatar_url from owners where array[ownerid] <@ $1 limit array_length($1, 1) diff --git a/legacy_migrations/migrations/legacy_sql/upgrades/v443.py b/legacy_migrations/migrations/legacy_sql/upgrades/v443.py index 1e60eb31ac..59c1945cfc 100644 --- a/legacy_migrations/migrations/legacy_sql/upgrades/v443.py +++ b/legacy_migrations/migrations/legacy_sql/upgrades/v443.py @@ -44,25 +44,25 @@ def run_sql(schema_editor): begin select array( with recursive tree as ( - select ownerid, - service_id, + select ownerid, + service_id, array[]::text[] as ancestors_service_id, 1 as depth - from owners - where parent_service_id is null - and service = 'gitlab' + from owners + where parent_service_id is null + and service = 'gitlab' and ownerid = $1 union all - select owners.ownerid, - owners.service_id, + select owners.ownerid, + owners.service_id, tree.ancestors_service_id || owners.parent_service_id, depth + 1 as depth from owners, tree where owners.parent_service_id = tree.service_id and depth <= 20 ) - select ownerid - from tree + select ownerid + from tree where $2 = any(tree.ancestors_service_id) ) into _decendents_owner_ids; @@ -84,7 +84,7 @@ def run_sql(schema_editor): begin select o.service, o.service_id into _service, _service_id from owners o where o.ownerid = $1; - + if _service = 'gitlab' then select get_gitlab_repos_activated($1, _service_id) into _repos_activated; else @@ -147,12 +147,12 @@ def run_sql(schema_editor): if not found then insert into owners (service, service_id, username, name, email, avatar_url, parent_service_id) - values ($1, - (_team.d->>'id')::text, - (_team.d->>'username')::citext, - (_team.d->>'name')::text, - (_team.d->>'email')::text, - (_team.d->>'avatar_url')::text, + values ($1, + (_team.d->>'id')::text, + (_team.d->>'username')::citext, + (_team.d->>'name')::text, + (_team.d->>'email')::text, + (_team.d->>'avatar_url')::text, (_team.d->>'parent_id')::text ) returning ownerid into _ownerid; diff --git a/legacy_migrations/migrations/legacy_sql/upgrades/v448.py b/legacy_migrations/migrations/legacy_sql/upgrades/v448.py index 11265e6211..14960bb385 100644 --- a/legacy_migrations/migrations/legacy_sql/upgrades/v448.py +++ b/legacy_migrations/migrations/legacy_sql/upgrades/v448.py @@ -12,12 +12,12 @@ def run_sql(schema_editor): 'v4-10m', 'v4-10y', 'v4-20m', 'v4-20y', 'v4-50m', 'v4-50y', 'v4-125m', 'v4-125y', 'v4-300m', 'v4-300y', -- 'v4-10m', 'v4-10y', 'v4-20m', 'v4-20y', 'v4-50m', 'v4-50y', 'v4-125m', 'v4-125y', 'v4-300m', 'v4-300y', 'users', 'users-inappm', 'users-inappy', 'users-free'); -- 'users', 'users-inappm', 'users-inappy', 'users-free'); -- alter all enum columns - alter table owners + alter table owners alter column plan type plans using plan::text::plans; -- drop the old enum - drop type plans__; + drop type plans__; ALTER TABLE ONLY owners ALTER COLUMN plan SET DEFAULT 'users-free'; -- ALTER TABLE ONLY owners ALTER COLUMN plan SET DEFAULT 'users-free'; diff --git a/legacy_migrations/migrations/legacy_sql/upgrades/v451.py b/legacy_migrations/migrations/legacy_sql/upgrades/v451.py index 3369a6168c..0af6041576 100644 --- a/legacy_migrations/migrations/legacy_sql/upgrades/v451.py +++ b/legacy_migrations/migrations/legacy_sql/upgrades/v451.py @@ -9,11 +9,11 @@ def run_sql(schema_editor): -- Here we're commenting out all plan related migrations below because they break on enterprise -- these migrations have been run already for production, but can break some production - -- deployments. Specifically the setting of the plan column to a new default causes problems with - -- web's ability to migrate effectively in some scenarios. + -- deployments. Specifically the setting of the plan column to a new default causes problems with + -- web's ability to migrate effectively in some scenarios. -- If you're starting from scratch in dev, you will need to run the below migrations manually, - -- or comment out these migrations before starting up codecov.io for the first time. + -- or comment out these migrations before starting up codecov.io for the first time. -- This isn't ideal, and will hopefully be addressed when we move all migrations to Django. diff --git a/ruff.toml b/ruff.toml index 45826d564f..a824e1ef3a 100644 --- a/ruff.toml +++ b/ruff.toml @@ -36,8 +36,9 @@ indent-width = 4 target-version = "py312" [lint] -# Currently only enabled for F, I, and E rules, with a few exclusions: https://docs.astral.sh/ruff/rules/ -select = ["F", "I", "E"] +# Currently only enabled for F (Pyflakes), I (isort), E,W (pycodestyle:Error/Warning), PLC (Pylint:Convention) +# and PLE (Pylint:Error) rules: https://docs.astral.sh/ruff/rules/ +select = ["F", "I", "E", "W", "PLC", "PLE"] ignore = ["F841", "F401", "F405", "F403", "E501", "E712", "E711"] # Allow fix for all enabled rules (when `--fix`) is provided. diff --git a/services/analytics.py b/services/analytics.py index 87a74267dc..0039c28957 100644 --- a/services/analytics.py +++ b/services/analytics.py @@ -101,7 +101,7 @@ def context(self): context["Marketo"] = {"marketo_cookie": marketo_cookie} if ga_cookie: # id is everything after the "GA.1." prefix - match = re.match("^.+\.(.+?\..+?)$", ga_cookie) + match = re.match(r"^.+\.(.+?\..+?)$", ga_cookie) if match: ga_client_id = match.group(1) context["externalIds"].append( diff --git a/upload/helpers.py b/upload/helpers.py index 4ea26302d7..df9619f58a 100644 --- a/upload/helpers.py +++ b/upload/helpers.py @@ -294,7 +294,7 @@ def determine_repo_for_upload(upload_params): elif service: if not using_global_token: # verify CI TODO - + # Get repo info from CI TODO """ diff --git a/upload/urls.py b/upload/urls.py index d3695ec115..9ca6183673 100644 --- a/upload/urls.py +++ b/upload/urls.py @@ -58,5 +58,5 @@ name="new_upload.commits", ), # This was getting in the way of the new endpoints, so I moved to the end - re_path("(?P\w+)/?", UploadHandler.as_view(), name="upload-handler"), + re_path(r"(?P\w+)/?", UploadHandler.as_view(), name="upload-handler"), ]