| 1 | # LSP Test 1: Hover Information (F1) |
| 2 | # =================================== |
| 3 | # |
| 4 | # Instructions: |
| 5 | # 1. Place cursor on any symbol below |
| 6 | # 2. Press F1 to see hover information |
| 7 | # 3. Press Escape to dismiss the hover popup |
| 8 | # |
| 9 | # Try hovering over: |
| 10 | # - Function names (greet, calculate_area) |
| 11 | # - Variable names (message, radius) |
| 12 | # - Built-in functions (print, len, range) |
| 13 | # - Type names (str, int, float, list) |
| 14 | |
| 15 | def greet(name: str) -> str: |
| 16 | """Return a greeting message for the given name.""" |
| 17 | message = f"Hello, {name}!" |
| 18 | return message |
| 19 | |
| 20 | |
| 21 | def calculate_area(radius: float) -> float: |
| 22 | """Calculate the area of a circle given its radius.""" |
| 23 | import math |
| 24 | return math.pi * radius ** 2 |
| 25 | |
| 26 | |
| 27 | class Person: |
| 28 | """A simple Person class for testing hover.""" |
| 29 | |
| 30 | def __init__(self, name: str, age: int): |
| 31 | self.name = name |
| 32 | self.age = age |
| 33 | |
| 34 | def introduce(self) -> str: |
| 35 | """Return an introduction string.""" |
| 36 | return f"I'm {self.name}, {self.age} years old." |
| 37 | |
| 38 | |
| 39 | # Test area - place cursor on these and press F1: |
| 40 | result = greet("World") |
| 41 | area = calculate_area(5.0) |
| 42 | person = Person("Alice", 30) |
| 43 | intro = person.introduce() |
| 44 | |
| 45 | numbers = [1, 2, 3, 4, 5] |
| 46 | length = len(numbers) |
| 47 | |
| 48 | for i in range(10): |
| 49 | print(i) |