Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
__getattr__ and type hint
#1
Hi
I have a Foo class(its an abstract one) with the magic Method __getattr__
And i have also a Bar class which inherits Foo,

When Foo.__getattre__ is invoked, it invokes also some factory method within Bar, which returns another instance of Duck class.

My problem: i want to provide some “visible” methods to my IDE (pycharm) so that i will see those methods once i am typing my instance name and then “.” (without disabling the getattr magic method)

For instance, the factory method (Bar class) returns a Duck class.
So typing “Bar.” Will list all Duck interface

Thanks you guys!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Import a module for use in type hint? Milosz 0 1,487 Nov-08-2021, 06:49 PM
Last Post: Milosz
  what if __getattr__() can't find an attribute, either? Skaperen 1 1,465 Oct-08-2021, 08:43 PM
Last Post: Yoriz
  @property vs __set__ / __get__ and __setattr__ / __getattr__ okhajut 1 3,339 Jun-15-2021, 03:48 PM
Last Post: snippsat
  Type hinting - return type based on parameter micseydel 2 2,487 Jan-14-2020, 01:20 AM
Last Post: micseydel
  What is the correct type hint when you want to accept Iterable but not Dictionary LadySvetlana 4 3,328 Mar-05-2019, 07:33 PM
Last Post: LadySvetlana
  Type hint produces Syntax error Digamma 4 10,456 Apr-27-2018, 06:50 AM
Last Post: Digamma

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020