Browse Source

pre-commit: updated black to format for python 3.11 (#65750)

Change the configuration for `black` to target Python 3.11 for its
formatting rules.
Matthew T 1 year ago
parent
commit
6eae844b74
1 changed files with 63 additions and 59 deletions
  1. 63 59
      pyproject.toml

+ 63 - 59
pyproject.toml

@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
 [tool.black]
 # File filtering is taken care of in pre-commit.
 line-length = 100
-target-version = ['py38']
+target-version = ['py311']
 
 [tool.isort]
 profile = "black"
@@ -22,37 +22,41 @@ addopts = "-ra --tb=short --strict-markers -p no:celery --nomigrations"
 # TODO: --import-mode=importlib will become the default soon,
 # currently we have a few relative imports that don't work with that.
 markers = [
-    "snuba: test requires access to snuba",
-    "snuba_ci: test is run in snuba ci",
-    "sentry_metrics: test requires access to sentry metrics",
-    "symbolicator: test requires access to symbolicator",
+  "snuba: test requires access to snuba",
+  "snuba_ci: test is run in snuba ci",
+  "sentry_metrics: test requires access to sentry metrics",
+  "symbolicator: test requires access to symbolicator",
 ]
 filterwarnings = [
-    # Consider all warnings to be errors other than the ignored ones.
-    "error",
+  # Consider all warnings to be errors other than the ignored ones.
+  "error",
 
-    # a bunch of google packages use legacy namespace packages
-    "ignore:pkg_resources is deprecated as an API",
-    "ignore:Deprecated call to `pkg_resources.declare_namespace\\('google.*'\\)`.",
+  # a bunch of google packages use legacy namespace packages
+  "ignore:pkg_resources is deprecated as an API",
+  "ignore:Deprecated call to `pkg_resources.declare_namespace\\('google.*'\\)`.",
 
-    # this warning in protobuf causes a segfault in 3.12+ protocolbuffers/protobuf#15077
-    "ignore:Type google\\._upb.*",
+  # this warning in protobuf causes a segfault in 3.12+ protocolbuffers/protobuf#15077
+  "ignore:Type google\\._upb.*",
 
-    # The following warning filters are for pytest only.
-    # This is so we don't have to wrap most datetime objects in testing code
-    # with django.utils.timezone.
-    "ignore:DateTimeField.*naive datetime:RuntimeWarning",
-    "ignore:.*sentry.digests.backends.dummy.DummyBackend.*:sentry.utils.warnings.UnsupportedBackend",
+  # The following warning filters are for pytest only.
+  # This is so we don't have to wrap most datetime objects in testing code
+  # with django.utils.timezone.
+  "ignore:DateTimeField.*naive datetime:RuntimeWarning",
+  "ignore:.*sentry.digests.backends.dummy.DummyBackend.*:sentry.utils.warnings.UnsupportedBackend",
 
-    # pytest has not yet implemented the replacement for this yet
-    "ignore:The --looponfail command line argument.*",
+  # pytest has not yet implemented the replacement for this yet
+  "ignore:The --looponfail command line argument.*",
 ]
 looponfailroots = ["src", "tests"]
 
 [tool.mypy]
 python_version = "3.11"
 mypy_path = ["fixtures/stubs-for-mypy"]
-plugins = ["pydantic.mypy", "mypy_django_plugin.main", "tools.mypy_helpers.plugin"]
+plugins = [
+  "pydantic.mypy",
+  "mypy_django_plugin.main",
+  "tools.mypy_helpers.plugin",
+]
 files = ["."]
 exclude = ["^.venv/", "^venv/", "^self-hosted/"]
 
@@ -70,8 +74,8 @@ django_settings_module = "sentry.conf.server_mypy"
 # these have py.typed but incorrect types
 [[tool.mypy.overrides]]
 module = [
-    # TODO: these cause type errors when followed
-    "snuba_sdk.*",
+  # TODO: these cause type errors when followed
+  "snuba_sdk.*",
 ]
 follow_imports = "skip"
 
@@ -81,38 +85,38 @@ follow_imports = "skip"
 # - or find a 3rd party stub
 [[tool.mypy.overrides]]
 module = [
-    "boto3.*",
-    "botocore.client.*",
-    "botocore.exceptions.*",
-    "celery.*",
-    "confluent_kafka.*",
-    "cssselect.*",
-    "django_zero_downtime_migrations.backends.postgres.schema.*",
-    "docker.*",
-    "fido2.*",
-    "google.auth.*",
-    "google.cloud.pubsub_v1.*",
-    "google.cloud.storage.blob.*",
-    "google.cloud.storage.bucket.*",
-    "google.cloud.storage.client.*",
-    "google.resumable_media.common.*",
-    "google.rpc.status_pb2.*",
-    "google_crc32c.*",
-    "honcho.manager.*",
-    "honcho.printer.*",
-    "kombu.*",
-    "mistune.*",
-    "onelogin.saml2.auth.*",
-    "onelogin.saml2.constants.*",
-    "onelogin.saml2.idp_metadata_parser.*",
-    "phabricator.*",
-    "progressbar.*",
-    "rb.*",
-    "requests_oauthlib.*",
-    "sqlparse.*",
-    "statsd.*",
-    "u2flib_server.model.*",
-    "unidiff.*",
+  "boto3.*",
+  "botocore.client.*",
+  "botocore.exceptions.*",
+  "celery.*",
+  "confluent_kafka.*",
+  "cssselect.*",
+  "django_zero_downtime_migrations.backends.postgres.schema.*",
+  "docker.*",
+  "fido2.*",
+  "google.auth.*",
+  "google.cloud.pubsub_v1.*",
+  "google.cloud.storage.blob.*",
+  "google.cloud.storage.bucket.*",
+  "google.cloud.storage.client.*",
+  "google.resumable_media.common.*",
+  "google.rpc.status_pb2.*",
+  "google_crc32c.*",
+  "honcho.manager.*",
+  "honcho.printer.*",
+  "kombu.*",
+  "mistune.*",
+  "onelogin.saml2.auth.*",
+  "onelogin.saml2.constants.*",
+  "onelogin.saml2.idp_metadata_parser.*",
+  "phabricator.*",
+  "progressbar.*",
+  "rb.*",
+  "requests_oauthlib.*",
+  "sqlparse.*",
+  "statsd.*",
+  "u2flib_server.model.*",
+  "unidiff.*",
 ]
 ignore_missing_imports = true
 # end: missing 3rd party stubs
@@ -625,11 +629,11 @@ disable_error_code = [
 # beginning: stronger typing
 [[tool.mypy.overrides]]
 module = [
-    "src.sentry.tasks.on_demand_metrics",
-    "src.sentry.relay.config.metric_extraction",
-    "src.sentry.snuba.metrics.extraction",
-    "tests.sentry.tasks.test_on_demand_metrics",
-    "tests.sentry.relay.config.test_metric_extraction",
+  "src.sentry.tasks.on_demand_metrics",
+  "src.sentry.relay.config.metric_extraction",
+  "src.sentry.snuba.metrics.extraction",
+  "tests.sentry.tasks.test_on_demand_metrics",
+  "tests.sentry.relay.config.test_metric_extraction",
 ]
 disallow_untyped_defs = true
 # end: stronger typing