Browse Source

ref: bump mypy to 1.3.0 (#50488)

the main breaking change for us here is that mypy no longer considers
blank function bodies as "stub functions" (thinking they are in .pyi
files) and now differentiates the two
anthony sottile 1 year ago
parent
commit
d593cce0dd

+ 2 - 0
mypy.ini

@@ -241,6 +241,8 @@ ignore_missing_imports = True
 [mypy-django.*]
 ignore_missing_imports = True
 [mypy-docker.*]
+# XXX: our local docker/ folder now shadows docker-py
+follow_imports = skip
 ignore_missing_imports = True
 [mypy-google.*]
 ignore_missing_imports = True

+ 2 - 2
requirements-dev-frozen.txt

@@ -95,8 +95,8 @@ more-itertools==8.13.0
 msgpack==1.0.4
 msgpack-types==0.2.0
 multidict==6.0.4
-mypy==0.982
-mypy-extensions==0.4.3
+mypy==1.3.0
+mypy-extensions==1.0.0
 nodeenv==1.6.0
 oauthlib==3.1.0
 openai==0.27.0

+ 1 - 1
requirements-dev.txt

@@ -30,7 +30,7 @@ packaging>=21.3
 # for type checking
 lxml-stubs
 msgpack-types>=0.2.0
-mypy>=0.982
+mypy>=1.3.0
 types-beautifulsoup4
 types-cachetools
 types-freezegun

+ 1 - 1
src/sentry/db/models/base.py

@@ -43,7 +43,7 @@ class BaseModel(models.Model):  # type: ignore
     class Meta:
         abstract = True
 
-    objects = BaseManager[M]()
+    objects = BaseManager[M]()  # type: ignore
 
     update = update
 

+ 1 - 1
src/sentry/digests/backends/dummy.py

@@ -17,7 +17,7 @@ class DummyBackend(Backend):
         maximum_delay: Optional[int] = None,
         timestamp: Optional[float] = None,
     ) -> bool:
-        pass
+        return False
 
     def enabled(self, project: "Project") -> bool:
         return False

+ 1 - 0
src/sentry/release_health/base.py

@@ -413,6 +413,7 @@ class ReleaseHealthBackend(Service):
         now: Optional[datetime] = None,
     ) -> Sequence[CrashFreeBreakdown]:
         """Get stats about crash free sessions and stats for the last 1, 2, 7, 14 and 30 days"""
+        raise NotImplementedError
 
     def get_changed_project_release_model_adoptions(
         self,

+ 2 - 2
src/sentry/release_health/metrics.py

@@ -546,12 +546,12 @@ class MetricsReleaseHealthBackend(ReleaseHealthBackend):
                 max_date = max_date2
 
         if min_date is not None and max_date is not None:
-            return {  # type: ignore
+            return {
                 "sessions_lower_bound": iso_format_snuba_datetime(min_date),
                 "sessions_upper_bound": iso_format_snuba_datetime(max_date),
             }
         else:
-            return {  # type: ignore
+            return {
                 "sessions_lower_bound": None,
                 "sessions_upper_bound": None,
             }

+ 2 - 2
src/sentry/rules/history/base.py

@@ -45,7 +45,7 @@ class RuleHistoryBackend(Service):
         Fetches groups that triggered a rule within a given timeframe, ordered by number of
         times each group fired.
         """
-        pass
+        raise NotImplementedError
 
     def fetch_rule_hourly_stats(
         self, rule: Rule, start: datetime, end: datetime
@@ -54,4 +54,4 @@ class RuleHistoryBackend(Service):
         Fetches counts of how often a rule has fired withing a given datetime range, bucketed by
         hour.
         """
-        pass
+        raise NotImplementedError

+ 1 - 1
src/sentry/runner/commands/devservices.py

@@ -65,7 +65,7 @@ def get_docker_client() -> Generator[docker.DockerClient, None, None]:
 @overload
 def get_or_create(
     client: docker.DockerClient, thing: Literal["network"], name: str
-) -> docker.modlels.networks.Network:
+) -> docker.models.networks.Network:
     ...
 
 

+ 3 - 3
src/sentry/services/hybrid_cloud/user_option/impl.py

@@ -33,7 +33,7 @@ class DatabaseBackedUserOptionService(UserOptionService):
         return self._FQ.get_many(filter)
 
     def delete_options(self, *, option_ids: List[int]) -> None:
-        UserOption.objects.filter(id__in=option_ids).delete()  # type: ignore
+        UserOption.objects.filter(id__in=option_ids).delete()
 
     def set_option(
         self,
@@ -44,7 +44,7 @@ class DatabaseBackedUserOptionService(UserOptionService):
         project_id: int | None = None,
         organization_id: int | None = None,
     ) -> None:
-        UserOption.objects.set_value(  # type: ignore
+        UserOption.objects.set_value(
             user=user_id,
             key=key,
             value=value,
@@ -56,7 +56,7 @@ class DatabaseBackedUserOptionService(UserOptionService):
         FilterQueryDatabaseImpl[UserOption, UserOptionFilterArgs, RpcUserOption, None]
     ):
         def base_query(self) -> QuerySet:
-            return UserOption.objects  # type: ignore
+            return UserOption.objects
 
         def filter_arg_validator(self) -> Callable[[UserOptionFilterArgs], Optional[str]]:
             return self._filter_has_any_key_validator("user_ids")

Some files were not shown because too many files changed in this diff