diff --git a/pyrefly/lib/alt/function.rs b/pyrefly/lib/alt/function.rs index fa4a8098f4..31c5f2328a 100644 --- a/pyrefly/lib/alt/function.rs +++ b/pyrefly/lib/alt/function.rs @@ -1203,10 +1203,6 @@ impl<'a, Ans: LookupAnswer> AnswersSolver<'a, Ans> { errors: &ErrorCollector, ) { let name = match decorator { - SpecialDecorator::StaticMethod(name) => name.as_str(), - SpecialDecorator::ClassMethod(name) => name.as_str(), - SpecialDecorator::Property(name) => name.as_str(), - SpecialDecorator::CachedProperty(name) => name.as_str(), SpecialDecorator::EnumMember => "member", SpecialDecorator::Override => "override", SpecialDecorator::Final => "final", diff --git a/pyrefly/lib/test/decorators.rs b/pyrefly/lib/test/decorators.rs index d6ffec6807..cf57a95265 100644 --- a/pyrefly/lib/test/decorators.rs +++ b/pyrefly/lib/test/decorators.rs @@ -246,16 +246,12 @@ testcase!( test_invalid_top_level_function_decorators, r#" from typing import * -from abc import abstractstaticmethod, abstractmethod # E: `abstractstaticmethod` is deprecated +from abc import abstractmethod from enum import member, nonmember @member # E: can only be used on methods @nonmember # E: can only be used on methods @abstractmethod # E: can only be used on methods -@staticmethod # E: can only be used on methods -@classmethod # E: can only be used on methods -@abstractstaticmethod # E: can only be used on methods -@property # E: can only be used on methods @final # E: can only be used on methods @override # E: can only be used on methods def f(x: int) -> int: @@ -263,6 +259,55 @@ def f(x: int) -> int: "#, ); +testcase!( + test_top_level_descriptor_decorators, + r#" +from typing import assert_type + +def make_property(): + @property + def x(self: "Point") -> int: + return self._x + + return x + + +class Point: + def __init__(self, x: int): + self._x = x + + x = make_property() + + +assert_type(Point(1).x, int) + +@staticmethod +def utility(x: int) -> int: + return x * 2 + + +class Helper: + compute = utility + + +assert_type(Helper.compute(5), int) + +@classmethod +def from_value(cls, val: int) -> "Container": + obj = cls() + obj.value = val + return obj + + +class Container: + value: int = 0 + from_value = from_value + + +assert_type(Container.from_value(42), Container) + "#, +); + testcase!( test_callable_class_as_decorator, r#" diff --git a/pyrefly/lib/test/lsp/lsp_interaction/pytorch_benchmark.rs b/pyrefly/lib/test/lsp/lsp_interaction/pytorch_benchmark.rs index cf56f84412..62429ffd53 100644 --- a/pyrefly/lib/test/lsp/lsp_interaction/pytorch_benchmark.rs +++ b/pyrefly/lib/test/lsp/lsp_interaction/pytorch_benchmark.rs @@ -48,7 +48,7 @@ fn test_pytorch_error_propagation_latency() { }; // Use all available cores for realistic benchmarking let mut interaction = - LspInteraction::new_with_args(args, NoTelemetry, Some(ThreadCount::AllThreads)); + LspInteraction::new_with_args(args, NoTelemetry, Some(ThreadCount::AllThreads), None); interaction.set_root(pytorch_root.clone()); interaction