Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Harmonize imports of sqlalchemy module, use sa where applicable #10

Merged
merged 2 commits into from
Dec 21, 2023

Conversation

amotl
Copy link
Contributor

@amotl amotl commented Dec 16, 2023

About

The patch follows a convention to import SQLAlchemy like import sqlalchemy as sa.

In this spirit, all references, even simple ones like symbols to SQLAlchemy base types like TEXT, or BIGINT, will be referenced by sa.TEXT, sa.BIGINT, etc., so it is easy to tell them apart when harmonizing type definitions coming from SA's built-in dialects vs. type definitions coming from 3rd-party dialects.

References

Copy link

codecov bot commented Dec 16, 2023

Codecov Report

Attention: 16 lines in your changes are missing coverage. Please review.

Comparison is base (2cfd7bb) 82.23% compared to head (3e3c6ec) 82.12%.

Files Patch % Lines
target_cratedb/sinks.py 37.50% 10 Missing ⚠️
target_cratedb/connector.py 71.42% 4 Missing ⚠️
target_cratedb/tests/test_standard_target.py 90.47% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #10      +/-   ##
==========================================
- Coverage   82.23%   82.12%   -0.11%     
==========================================
  Files           7        7              
  Lines         681      677       -4     
==========================================
- Hits          560      556       -4     
  Misses        121      121              
Flag Coverage Δ
main 82.12% <68.62%> (-0.11%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines -8 to 9
import sqlalchemy
import sqlalchemy as sa
from crate.client.sqlalchemy.types import ObjectType, ObjectTypeImpl, _ObjectArray
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That we need to import both ObjectType and ObjectTypeImpl here, and use them correspondingly, clearly indicates something is not optimal, and should be addressed on behalf of improvements to the type definitions of the CrateDB SQLAlchemy dialect in crate-python.

@amotl amotl requested review from seut, matriv and surister December 16, 2023 05:57
@amotl amotl marked this pull request as ready for review December 16, 2023 05:57
Copy link

@seut seut left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link

@surister surister left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Base automatically changed from tests to main December 21, 2023 19:33
It follows a convention to import SQLAlchemy like
`import sqlalchemy as sa`. In this spirit, all references, even simple
ones like symbols to SQLAlchemy base types like `TEXT`, or `BIGINT`,
will be referenced by `sa.TEXT`, `sa.BIGINT`, etc., so it is easy to
tell them apart when harmonizing type definitions coming from SA's
built-in dialects vs. type definitions coming from 3rd-party dialects.
@amotl amotl force-pushed the harmonize-sqlalchemy branch from 74296f7 to ab563dc Compare December 21, 2023 19:37
- Enforce `import typing as t` alias
- Ban imports such as `from typing import Any`
@amotl
Copy link
Contributor Author

amotl commented Dec 21, 2023

Interesting comment by @edgarrmondragon at MeltanoLabs/target-postgres#255 (comment):

Probably overkill for this to introduce Ruff, but it can enforce this type of import conventions. For example, the singer SDK enforces the import typing as t alias and bans imports such as from typing import Any: https://github.com/meltano/sdk/blob/0192d5875345a9d8ab42e81d261084290bd456d0/pyproject.toml#L333-L337

I didn't know about this detail of Ruff yet, thanks! 3e3c6ec adds the corresponding snippet.

@amotl amotl merged commit 6b44b8d into main Dec 21, 2023
2 of 4 checks passed
@amotl amotl deleted the harmonize-sqlalchemy branch December 21, 2023 19:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants