filetype.py icon indicating copy to clipboard operation
filetype.py copied to clipboard

add_type always fails

Open TheMaddScientist opened this issue 5 years ago • 1 comments

If you attempt to do an add_type with a subclass of Type, you always get the "instance must inherit from filetype.types.Type". This appears to be because isinstance only returns true for actual instances and not for subclasses. You need to use issubclass to check for subclasses. I am using Python 3.8, so this may be new behavior.

If I fix this error, I get a further buffer error. Attached is a zip file with my example code. You will need to change the file locations. detect_file_type.zip

TheMaddScientist avatar Jul 03 '20 18:07 TheMaddScientist

@TheMaddScientist No, isintance is the correct call but you need to add an instance of your tLilyPond class!

ft.add_type(tLilyPond())

dosas avatar Dec 20 '20 20:12 dosas