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

[CT-2980] Fix untyped functions in adapters/base/ (mypy warning) #8396

Closed
Tracked by #8387
emmyoop opened this issue Aug 14, 2023 · 5 comments · Fixed by #8485
Closed
Tracked by #8387

[CT-2980] Fix untyped functions in adapters/base/ (mypy warning) #8396

emmyoop opened this issue Aug 14, 2023 · 5 comments · Fixed by #8485
Assignees
Labels
tech_debt Behind-the-scenes changes, with little direct impact on end-user functionality

Comments

@emmyoop
Copy link
Member

emmyoop commented Aug 14, 2023

Problem

When we hit a mypy error the console is flooded with mypy warnings as well. Clean up the warning to improve developer experience.

Reproduction

Simply force a mypy error (change types) and the warnings will be generated.

Relevant Output

core/dbt/adapters/base/query_headers.py:29: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs  [annotation-unchecked]
core/dbt/adapters/base/impl.py:229: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs  [annotation-unchecked]
@github-actions github-actions bot changed the title Fix untyped functions in adapters/base/impl.py (mypy warning) [CT-2980] Fix untyped functions in adapters/base/impl.py (mypy warning) Aug 14, 2023
@emmyoop emmyoop added the tech_debt Behind-the-scenes changes, with little direct impact on end-user functionality label Aug 14, 2023
@emmyoop emmyoop changed the title [CT-2980] Fix untyped functions in adapters/base/impl.py (mypy warning) [CT-2980] Fix untyped functions in adapters/base/ (mypy warning) Aug 14, 2023
@gshank
Copy link
Contributor

gshank commented Aug 18, 2023

The query_headers one has been fixed. The one at core/dbt/adapters/base/impl.py:229 is harder. It uses a Protocol which is way underspecified, but it's not clear to me what it ought to be. This one might more appropriately be looked at by an adapters dev.

core/dbt/adapters/base/impl.py:228: error: Too many arguments for "ConnectionManagerProtocol"  [call-arg]
core/dbt/adapters/base/impl.py:235: error: "ConnectionManagerProtocol" has no attribute "set_connection_name"  [attr-defined]
core/dbt/adapters/base/impl.py:238: error: "ConnectionManagerProtocol" has no attribute "release"  [attr-defined]
core/dbt/adapters/base/impl.py:241: error: "ConnectionManagerProtocol" has no attribute "cleanup_all"  [attr-defined]
core/dbt/adapters/base/impl.py:244: error: "ConnectionManagerProtocol" has no attribute "clear_transaction"  [attr-defined]
core/dbt/adapters/base/impl.py:247: error: "ConnectionManagerProtocol" has no attribute "commit_if_has_connection"  [attr-defined]
core/dbt/adapters/base/impl.py:253: error: "ConnectionManagerProtocol" has no attribute "get_if_exists"  [attr-defined]
core/dbt/adapters/base/impl.py:261: error: "ConnectionManagerProtocol" has no attribute "query_header"  [attr-defined]
core/dbt/adapters/base/impl.py:262: error: "ConnectionManagerProtocol" has no attribute "query_header"  [attr-defined]
core/dbt/adapters/base/impl.py:267: error: "ConnectionManagerProtocol" has no attribute "query_header"  [attr-defined]
core/dbt/adapters/base/impl.py:268: error: "ConnectionManagerProtocol" has no attribute "query_header"  [attr-defined]
core/dbt/adapters/base/impl.py:290: error: "ConnectionManagerProtocol" has no attribute "execute"  [attr-defined]
core/dbt/adapters/base/impl.py:306: error: "ConnectionManagerProtocol" has no attribute "add_select_query"  [attr-defined]
core/dbt/adapters/base/impl.py:309: error: "ConnectionManagerProtocol" has no attribute "data_type_code_to_name"  [attr-defined]
core/dbt/adapters/base/impl.py:325: error: "ConnectionManagerProtocol" has no attribute "get_partitions_metadata"  [attr-defined]
core/dbt/adapters/base/impl.py:360: error: "ConnectionManagerProtocol" has no attribute "set_query_header"  [attr-defined]
core/dbt/adapters/base/impl.py:459: error: Argument 1 to "update_schemas" of "RelationsCache" has incompatible type "Set[Tuple[Optional[str], Optional[str]]]"; expected "Iterable[Tuple[Optional[str], str]]"  [arg-type]
core/dbt/adapters/base/impl.py:1053: error: "ConnectionManagerProtocol" has no attribute "exception_handler"  [attr-defined]
core/dbt/adapters/base/impl.py:1271: error: "ConnectionManagerProtocol" has no attribute "profile"  [attr-defined]

@gshank
Copy link
Contributor

gshank commented Aug 18, 2023

@mikealfare If you get a chance, could you take a look?

@mikealfare
Copy link
Contributor

@gshank Is there a branch in progress that I should start from or just peel another off of main?

@gshank
Copy link
Contributor

gshank commented Aug 21, 2023

Just from main is fine. You see the issues if you add a return value -> None to the init method of BaseAdapter

@mikealfare
Copy link
Contributor

@gshank can you take a look at what I did in #8485 to see if it aligns with how we're resolving these issues elsewhere?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tech_debt Behind-the-scenes changes, with little direct impact on end-user functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants