matrix-org / sygnal

Sygnal: reference Push Gateway for Matrix
Apache License 2.0
160 stars 144 forks source link

Use absolute imports for consistency #265

Closed squahtx closed 2 years ago

richvdh commented 2 years ago

I'm keen for consistency, and neutral on whether we should prefer relative or absolute imports.

I thought this was explicitly covered by https://github.com/matrix-org/synapse/blob/develop/docs/code_style.md, but it seems I thought wrong.

In the absence of our own rules, we generally defer to Google's style guide, which is generally comprehensive and well-reasoned. In this case it says:

Import each module using the full pathname location of the module.

richvdh commented 2 years ago

(and also:

Do not use relative names in imports.

)

squahtx commented 2 years ago

Is there a linter check we can use to enforce this?

A quick search found https://github.com/MarcoGorelli/absolufy-imports which will reformat your imports, and https://pypi.org/project/flake8-absolute-import/