OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Is there any method to convert TypeVar to type in python?

  • Thread starter Thread starter Satoshi
  • Start date Start date
S

Satoshi

Guest
I want to convert TypeVar variable to type.
Sample code:

Code:
class Data:
  @classmethod
  def some_method(cls):
    pass

class SomeData(Data):
  pass

class Dealer[T:Data]:
  ...
  def some_method2(self):
    T.some_method() <--- Unresolved attribute reference 'some_method' for class 'TypeVar'

def main():
  dealer=Dealer[SomeData]()
  dealer.some_method2()

Is there any way to call "some_method"?
<p>I want to convert TypeVar variable to type.<br />
Sample code:</p>
<pre><code>class Data:
@classmethod
def some_method(cls):
pass

class SomeData(Data):
pass

class Dealer[T:Data]:
...
def some_method2(self):
T.some_method() <--- Unresolved attribute reference 'some_method' for class 'TypeVar'

def main():
dealer=Dealer[SomeData]()
dealer.some_method2()
</code></pre>
<p>Is there any way to call "some_method"?</p>
 
Top