If I understand your question correctly, you should be able to reference class A within class A by putting the type annotation in quotes. This is called forward reference.

class A:
  # do something
  def some_func(self, a: 'A')
  # ...

See ref below

  1. https://github.com/python/mypy/issues/3661
  2. https://www.youtube.com/watch?v=AJsrxBkV3kc
Answer from Chin Pang Yau on Stack Overflow
🌐
Python documentation
docs.python.org › 3 › tutorial › classes.html
9. Classes — Python 3.14.8 documentation
5 days ago - The original local scope (the one in effect just before the class definition was entered) is reinstated, and the class object is bound here to the class name given in the class definition header (ClassName in the example). Class objects support two kinds of operations: attribute references and instantiation.
Discussions

How to reference the class itself in python - Stack Overflow
It could be a variable belonging to the class, method belonging to the class. I want something like self is referencing the instance of the class, but referencing the class. ... in classmethods the first argument passed to function is class (commonly denoted cls) docs.python.org/2/library/... More on stackoverflow.com
🌐 stackoverflow.com
How to reference class variables inside class method
Do you ever set parameters? One, that type hint is actually for instance variables; despite the location, and two, the type hint doesn't create data. It's just a type hint. More on reddit.com
🌐 r/learnpython
11
2
November 5, 2022
How to reference a class variable in python - Stack Overflow
I cant seem to get the classes to read the alive dictionary it keeps throwing a NameError: global name 'import_1' is not defined I am using this guide: http://www.ibiblio.org/g2swap/byteofpython/... More on stackoverflow.com
🌐 stackoverflow.com
python - Class Referencing - Stack Overflow
The reason I am asking is in class ... in class1.py, so will I thought giving it a namespace will allow me to reference properly. ... could you please change the title, because super means something else and it might get confuse who search for super in python.... More on stackoverflow.com
🌐 stackoverflow.com
February 19, 2014
🌐
Stack Overflow
stackoverflow.com › questions › 50200657 › how-do-i-reference-to-a-class-using-a-string-in-python
How do I reference to a class using a string in python? - Stack Overflow
What you want to do is make userClass an instance of class X, basing from your code. ... AttributeErrors occur when you are accessing a non-existent attribute in an object. In Python, it's recommended that you use snake case instead of camel case. I.e. userName would be user_name.
🌐
Learning About Electronics
learningaboutelectronics.com › Articles › How-to-create-and-reference-a-class-variable-in-Python.php
How to Create and Reference a Class Variable in Python
We then create another variable, Student1_finalscore and set it equal to the raw score * the test curve, which gives us the final score. So this is one way we can reference a class variable in Python.
🌐
Reddit
reddit.com › r/learnpython › how to reference class variables inside class method
r/learnpython on Reddit: How to reference class variables inside class method
November 5, 2022 -
class Test:
    config: Dict[str, str]
    parameters: Dict[str, str]

    def default(cls)
        return cls(
                parameters=get_params(),
                config=get_config(file="ATTRIBUTE FROM PARAMETERS"
        )
# I tried it like this:

class Test:
    config: Dict[str, str]
    parameters: Dict[str, str]

    def default(cls)
        return cls(
                parameters=get_params(),
                config=get_config(file=cls.parameters.config_file)
        )
# AttributeError: type object 'Test' has no attribute 'parameters'
🌐
w3tutorials
w3tutorials.net › blog › self-referencing-class-definition-in-python
Self-Referencing Class Definition in Python: How to Reference the Class Name Within Its Declaration — w3tutorials.net
The critical detail here is: during the execution of the class body, the class object does not exist yet, and the name MyClass is not bound in the scope. If you try to reference MyClass inside the body (e.g., x = MyClass), Python raises a NameError because MyClass hasn’t been defined yet.
Find elsewhere
🌐
TutorialsPoint
tutorialspoint.com › How-do-we-reference-Python-class-attributes
How do we reference Python class attributes?
April 15, 2025 - Access both types using dot notation, but remember that class attribute changes affect all instances while instance attribute changes are isolated to individual objects.
🌐
Bite Code
bitecode.dev › bite code! › holding references on classes and functions
Holding references on classes and functions - Bite code!
December 20, 2023 - However there are many other ways to create a variable in Python. The first one is, surprisingly, the import statement: ... This will set the variable datetime in the current namespace, and make it hold a reference to the module object loaded from "datetime.py" in the stdlib.
🌐
W3Schools
w3schools.com › python › python_classes.asp
Python Classes
Almost everything in Python is an object, with its properties and methods. A Class is like an object constructor, or a "blueprint" for creating objects. ... Note: Each object is independent and has its own copy of the class properties. class definitions cannot be empty, but if you for some reason have a class definition with no content, put in the pass statement to avoid getting an error.
🌐
Python Reference
python-reference.readthedocs.io › en › latest › docs › functions › classmethod.html
classmethod — Python Reference (The Right Way) 0.1 documentation
>>> #This example shows obsolete syntax >>> #Note that method bar can be called on both class and instance objects >>> class Foo: ... def bar(cls): # ... print 'bar’ # ... bar = classmethod(bar) #<= not pythonic anymore, decorator syntax recommended ... >>> Foo.bar <bound method classobj.bar of <class __main__.Foo at 0x00CDAC00>> >>> Foo.bar() bar >>> Foo().bar <bound method classobj.bar of <class __main__.Foo at 0x00CDAC00>> >>> Foo().bar() bar
🌐
University of Chicago Library
www2.lib.uchicago.edu › keith › courses › python › class › 5
Introduction to Python: Class 5
Now we can explain class and instance attribute reference in detail. When looking up an attribute via a class object C, Python first searches the class's name space (C.__dict__); if it doesn't find the attribute, it then recursively searches the class's base classes, left to right and depth first.
🌐
Stack Overflow
stackoverflow.com › questions › 69201113 › python-best-way-to-set-a-reference-for-a-class-attribute-that-has-not-been-defi
Python: Best way to set a reference for a class attribute that has not been defined yet and what default to use? - Stack Overflow
Alternatively, create a WinnerOf class that stores a Match attribute. The name attribute getter could then return None or the player name. In Match, m1 and m2 could be Player or WinnerOf objects. Both ideas boil down to storing a reference to the Match object whose outcome is not known yet, either directly or indirectly. ... How to set python ...
🌐
Altcademy
altcademy.com › blog › how-to-call-a-class-in-python
How to call a class in Python - Altcademy.com
September 10, 2023 - For instance, 'Car' is a concept, and 'my_car' is a specific instance of that concept. A 'Car' has some properties like color, model, brand etc. Similarly, a Python class can have properties and functions. ```python class Car: color = "red" brand = "Toyota" my_car = Car() print(my_car.color) # prints: red print(my_car.brand) # prints: Toyota
🌐
Stack Overflow
stackoverflow.com › questions › 56340311 › how-to-reference-to-the-existing-object-of-class-in-python-from-string
How to reference to the existing object of class in Python from string? - Stack Overflow
I've got the problem with reference to the object. Function returns string="nameofexistingclass" and I would like to pass the string as an object and not as a class. User choose in the GUI of the existing instance of Person(self.name, self.ID) --> string with name of choosen class --> set another object of different class demanding choosen class.: Classify(person) Python demands to set the self.name, self.ID, but they exist before even choosing.
🌐
Python Like You Mean It
pythonlikeyoumeanit.com › Module4_OOP › ClassInstances.html
Instances of a Class — Python Like You Mean It
It is important to understand that this new instance is distinct from the one that we already created. # `d2` is a new instance of our Dummy class. # It resides at a distinct memory address (0x2ae8f666f60) >>> d2 = Dummy() >>> d2 <__main__.Dummy at 0x2ae8f666f60> >>> d2 is d1 # `d2` and `d1` are distinct instances of `Dummy` False >>> isinstance(d2, Dummy) True · Python’s rules for referencing objects with variables still apply here: assigning an object to a variable, be it a class object or an instance, does not create a distinct copy of that object.