Skip to content

Instantly share code, notes, and snippets.

@hoosnick
Created August 20, 2025 18:30
Show Gist options
  • Select an option

  • Save hoosnick/4a67ada9a454545045419a0abba330ca to your computer and use it in GitHub Desktop.

Select an option

Save hoosnick/4a67ada9a454545045419a0abba330ca to your computer and use it in GitHub Desktop.
Code from Telegraph article
from typing import final
class Report:
  def generate_header(self):
    return "--- Company Header ---"
  @final
  def build_report(self) -> str:
    # Бу методнинг логикаси ўзгармас бўлиши керак
    header = self.generate_header()
    body = "This is the main content."
    return f"{header}\n{body}"
class FinancialReport(Report):
  # Оддий методни қайта ёзиш мумкин
  def generate_header(self):
    return "--- Financial Report Header ---"
  # @final методни қайта ёзишга уриниш
  def build_report(self) -> str: # <-- MyPy хато беради!
    return "Oops, I broke the logic."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment