PyEED / pyeed

🧬 Toolkit to create, annotate, and analyze specialized sequence databases
https://pyeed.github.io/pyeed/
MIT License
3 stars 4 forks source link

Fix circular import for `ProteinRecord` #68

Closed JR-1991 closed 6 months ago

JR-1991 commented 6 months ago

There was a circular import die to the family of XYZMapper classes that import ProteinRecord. Due to the sdRDM action pulling imports from all-over the code to the top, the circular dependency cannot be resolved by leaving the import within the method in ProteinRecord.

This PR inverts the problem and pulls the ProteinRecord into the XYZMapper class methods. For type annotations that are using ProteinRecord the TYPE_CHECKING pattern has been employed to preserve type checking while not inducing circular imports. I have also added a test to check circular dependencies.

I would advise you to pull out any higher logic from the core module to prevent this from happening.

JR-1991 commented 6 months ago

I have changed the psycopg2 dependency to psycopg2-binary since the former requires external binaries, often leading to problems upon installing the library. I hate this 😵