-
Notifications
You must be signed in to change notification settings - Fork 4
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
CI: Move Ruff rules to dedicated ruff.toml
config, and add pre-commit
setup
#184
base: main
Are you sure you want to change the base?
CI: Move Ruff rules to dedicated ruff.toml
config, and add pre-commit
setup
#184
Conversation
ruff.toml
config, and add pre-commit
setup
ruff.toml
config, and add pre-commit
setupruff.toml
config, and add pre-commit
setup
📝 WalkthroughWalkthroughThis pull request introduces a comprehensive set of changes across the Airbyte CDK repository, primarily focusing on adding copyright notices, enhancing workflow configurations, and introducing new configuration files. The modifications span multiple directories, including GitHub Actions workflows, pre-commit configurations, and various Python modules, with an emphasis on standardizing code formatting, licensing, and build processes. Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Would you like me to elaborate on any specific aspect of these changes? 🤔 What do you think about the comprehensive updates to the repository's configuration and testing infrastructure? wdyt? Tip CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🔭 Outside diff range comments (2)
airbyte_cdk/sources/declarative/models/declarative_component_schema.py (2)
Line range hint
61-160
: Confirm if user-supplied strings are adequately sanitized.Many fields rely on user-provided configurations (like custom class names, tokens, etc.). Are we confident that these inputs won't create security issues (e.g., path traversal in dynamic imports)? Maybe you can consider a validation or safer import approach, wdyt?
Line range hint
161-320
: Check if you want to unify the “parameters” usage.We see repeated usage of Optional[Dict[str, Any]] named “parameters” across classes. Is there a uniform approach or base class that might consolidate this field’s behavior to reduce duplication, wdyt?
🧹 Nitpick comments (11)
unit_tests/sources/streams/concurrent/test_helpers.py (4)
Line range hint
6-8
: Consider adding a docstring for better documentation?The test is well-written and follows BDD naming, but what do you think about adding a brief docstring to explain the purpose and expected behavior? Something like:
def test_given_primary_key_is_list_of_strings_when_get_primary_key_from_stream_then_assume_it_is_composite_key_and_return_as_is(): """Verify that a list of strings is treated as a composite key and returned unchanged.""" result = get_primary_key_from_stream(["composite_id_1", "composite_id_2"]) assert result == ["composite_id_1", "composite_id_2"]wdyt?
Line range hint
11-13
: Consider adding input immutability check?The test looks good! Would it be valuable to add an assertion verifying that the original input remains unchanged after the function call? This could help catch any accidental mutations, wdyt?
def test_given_primary_key_is_composite_in_nested_lists_when_get_primary_key_from_stream_then_flatten_lists(): input_value = [["composite_id_1"], ["composite_id_2"]] original = [x[:] for x in input_value] # Deep copy result = get_primary_key_from_stream(input_value) assert result == ["composite_id_1", "composite_id_2"] assert input_value == original # Verify input wasn't modified
Line range hint
16-18
: How about verifying the error message too?The error case testing is great! Would it be helpful to also verify the error message to ensure it provides meaningful feedback? Something like:
def test_given_nested_key_when_get_primary_key_from_stream_then_raise_error(): with pytest.raises(ValueError, match="Expected flat list of strings or list of single-item lists"): get_primary_key_from_stream([["composite_id_1", "composite_id_2"]])
Line range hint
1-18
: Consider adding tests for additional edge cases?The current test coverage is good for the basic scenarios! Would it be valuable to add tests for:
- Empty list input
- Non-string values in the list
- None input
- Single string input (not in a list)
These would help ensure robust handling of edge cases. Happy to help draft these if you're interested! wdyt?
airbyte_cdk/sources/declarative/models/declarative_component_schema.py (3)
Line range hint
1-60
: Ponder re-grouping related classes into separate modules?This file is quite large, hosting a variety of classes (authentication, pagination, transformations, etc.). Splitting them into smaller modules might improve clarity and modularity, wdyt?
Line range hint
321-620
: Evaluate potential synergy of multiple OAuth classes.We have multiple OAuth-related classes (OAuthAuthenticator, RefreshTokenUpdater, OAuthConfigSpecification, etc.). Is there a risk of duplication or confusion between them? Maybe stepping back to see if they can be combined or made more compositional for easier maintenance, wdyt?
Line range hint
621-873
: Would you consider adding thorough unit tests for these data models?Since these models drive important workflows, a robust set of tests might help catch schema changes early. Possibly consider adding or enhancing tests for both happy and edge-case scenarios, wdyt?
airbyte_cdk/utils/slice_hasher.py (2)
Line range hint
1-12
: Add logging for serialization errors?Right now, if JSON serialization fails, a ValueError is raised. Logging may help troubleshoot specific slices. Would you consider logging the failing slice before raising the exception, wdyt?
Line range hint
13-24
: Consider clarifying “last 8 bytes of the hash” usage.Using only the last 8 bytes for the hash is interesting. Perhaps add a docstring explaining why 8 bytes are preferred. This might help new contributors understand this design choice, wdyt?
unit_tests/sources/declarative/stream_slicers/test_declarative_partition_generator.py (2)
Line range hint
37-80
: Add coverage for concurrency or partial failures?Currently, the tests focus on single-thread scenarios. Have you considered testing partial failures or concurrency use cases if any? Doing so might uncover more edge cases, wdyt?
Line range hint
81-103
: Check the final assertion style for consistency.We see a mix of
assert
statements andassert_called_once_with
. Maintaining a consistent approach (like using pytest’s style vs. rawassert
s) might improve readability, wdyt?
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (56)
.github/workflows/pypi_publish.yml
(1 hunks).pre-commit-config.yaml
(1 hunks)LICENSE_SHORT
(1 hunks)airbyte_cdk/cli/source_declarative_manifest/__init__.py
(1 hunks)airbyte_cdk/models/__init__.py
(2 hunks)airbyte_cdk/sources/declarative/async_job/__init__.py
(1 hunks)airbyte_cdk/sources/declarative/migrations/__init__.py
(1 hunks)airbyte_cdk/sources/declarative/models/__init__.py
(1 hunks)airbyte_cdk/sources/declarative/models/declarative_component_schema.py
(1 hunks)airbyte_cdk/sources/file_based/__init__.py
(1 hunks)airbyte_cdk/sources/file_based/availability_strategy/__init__.py
(1 hunks)airbyte_cdk/sources/file_based/config/__init__.py
(1 hunks)airbyte_cdk/sources/file_based/discovery_policy/__init__.py
(1 hunks)airbyte_cdk/sources/file_based/file_types/__init__.py
(1 hunks)airbyte_cdk/sources/file_based/schema_validation_policies/__init__.py
(1 hunks)airbyte_cdk/sources/file_based/stream/__init__.py
(1 hunks)airbyte_cdk/sources/file_based/stream/concurrent/__init__.py
(1 hunks)airbyte_cdk/sources/file_based/stream/concurrent/cursor/__init__.py
(1 hunks)airbyte_cdk/sources/file_based/stream/cursor/__init__.py
(1 hunks)airbyte_cdk/sources/streams/concurrent/state_converters/__init__.py
(1 hunks)airbyte_cdk/sql/__init__.py
(1 hunks)airbyte_cdk/sql/_util/__init__.py
(1 hunks)airbyte_cdk/test/mock_http/__init__.py
(1 hunks)airbyte_cdk/utils/slice_hasher.py
(1 hunks)pyproject.toml
(0 hunks)ruff.toml
(1 hunks)unit_tests/__init__.py
(1 hunks)unit_tests/destinations/__init__.py
(1 hunks)unit_tests/source_declarative_manifest/__init__.py
(1 hunks)unit_tests/source_declarative_manifest/resources/__init__.py
(1 hunks)unit_tests/sources/__init__.py
(1 hunks)unit_tests/sources/declarative/async_job/__init__.py
(1 hunks)unit_tests/sources/declarative/concurrency_level/__init__.py
(1 hunks)unit_tests/sources/declarative/decoders/__init__.py
(1 hunks)unit_tests/sources/declarative/incremental/__init__.py
(1 hunks)unit_tests/sources/declarative/migrations/__init__.py
(1 hunks)unit_tests/sources/declarative/stream_slicers/test_declarative_partition_generator.py
(1 hunks)unit_tests/sources/file_based/__init__.py
(1 hunks)unit_tests/sources/file_based/availability_strategy/__init__.py
(1 hunks)unit_tests/sources/file_based/config/__init__.py
(1 hunks)unit_tests/sources/file_based/discovery_policy/__init__.py
(1 hunks)unit_tests/sources/file_based/file_types/__init__.py
(1 hunks)unit_tests/sources/file_based/scenarios/__init__.py
(1 hunks)unit_tests/sources/file_based/stream/__init__.py
(1 hunks)unit_tests/sources/file_based/stream/concurrent/__init__.py
(1 hunks)unit_tests/sources/message/__init__.py
(1 hunks)unit_tests/sources/streams/__init__.py
(1 hunks)unit_tests/sources/streams/checkpoint/__init__.py
(1 hunks)unit_tests/sources/streams/concurrent/test_helpers.py
(1 hunks)unit_tests/sources/streams/http/__init__.py
(1 hunks)unit_tests/sources/streams/http/error_handlers/__init__.py
(1 hunks)unit_tests/sources/streams/http/requests_native_auth/__init__.py
(1 hunks)unit_tests/test/__init__.py
(1 hunks)unit_tests/test/mock_http/__init__.py
(1 hunks)unit_tests/test_counter.py
(0 hunks)unit_tests/utils/__init__.py
(1 hunks)
💤 Files with no reviewable changes (2)
- unit_tests/test_counter.py
- pyproject.toml
✅ Files skipped from review due to trivial changes (50)
- unit_tests/sources/init.py
- airbyte_cdk/sources/file_based/config/init.py
- unit_tests/sources/file_based/stream/init.py
- unit_tests/sources/declarative/decoders/init.py
- unit_tests/sources/file_based/stream/concurrent/init.py
- unit_tests/sources/file_based/discovery_policy/init.py
- airbyte_cdk/cli/source_declarative_manifest/init.py
- airbyte_cdk/sources/file_based/stream/cursor/init.py
- unit_tests/sources/file_based/init.py
- unit_tests/destinations/init.py
- airbyte_cdk/sources/file_based/discovery_policy/init.py
- unit_tests/test/mock_http/init.py
- unit_tests/sources/declarative/migrations/init.py
- airbyte_cdk/sql/init.py
- unit_tests/sources/streams/http/error_handlers/init.py
- airbyte_cdk/sources/streams/concurrent/state_converters/init.py
- unit_tests/sources/declarative/incremental/init.py
- unit_tests/sources/declarative/async_job/init.py
- unit_tests/source_declarative_manifest/init.py
- unit_tests/sources/declarative/concurrency_level/init.py
- airbyte_cdk/sources/declarative/async_job/init.py
- unit_tests/sources/file_based/file_types/init.py
- unit_tests/sources/streams/checkpoint/init.py
- unit_tests/sources/streams/http/requests_native_auth/init.py
- LICENSE_SHORT
- unit_tests/source_declarative_manifest/resources/init.py
- airbyte_cdk/sql/_util/init.py
- unit_tests/sources/file_based/config/init.py
- unit_tests/sources/streams/http/init.py
- airbyte_cdk/sources/declarative/models/init.py
- unit_tests/sources/file_based/availability_strategy/init.py
- airbyte_cdk/test/mock_http/init.py
- unit_tests/sources/message/init.py
- unit_tests/sources/streams/init.py
- unit_tests/sources/file_based/scenarios/init.py
- unit_tests/test/init.py
- unit_tests/utils/init.py
- airbyte_cdk/sources/file_based/stream/concurrent/cursor/init.py
- airbyte_cdk/sources/file_based/stream/concurrent/init.py
- airbyte_cdk/sources/file_based/stream/init.py
- ruff.toml
- airbyte_cdk/sources/file_based/availability_strategy/init.py
- airbyte_cdk/sources/declarative/migrations/init.py
- airbyte_cdk/models/init.py
- airbyte_cdk/sources/file_based/file_types/init.py
- unit_tests/init.py
- airbyte_cdk/sources/file_based/schema_validation_policies/init.py
- airbyte_cdk/sources/file_based/init.py
- .pre-commit-config.yaml
- .github/workflows/pypi_publish.yml
🔇 Additional comments (2)
unit_tests/sources/streams/concurrent/test_helpers.py (1)
1-3
: LGTM! Clean imports and proper copyright notice.
The imports are minimal and appropriate for the test file's needs.
unit_tests/sources/declarative/stream_slicers/test_declarative_partition_generator.py (1)
Line range hint 1-36
: Add a test documenting expected usage for empty slices?
It may be helpful to have a test demonstrating behavior when an empty slice is created. This could clarify the intended usage and corner-case coverage, wdyt?
Consolidate Ruff linting rules into a
ruff.toml
file and establish a pre-commit configuration to streamline code quality checks. Additionally, apply auto-formatting and fix minor formatting issues, including missing copyright text.Note:
pre-commit
is just added as an option to streamline the required auto-format steps (plus a bit more).Summary by CodeRabbit
New Features
SliceHasher
for computing hash values based on stream names and slices.Bug Fixes
DeclarativePartitionFactory
andget_primary_key_from_stream
to ensure correct functionality.Chores
pyproject.toml
to manage dependencies effectively.