fix(file_factory): drop doubled dot when standardizing datasource file extension#35808
Merged
Merged
Conversation
fatelei
approved these changes
May 6, 2026
Contributor
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-05-06 00:57:38.703000442 +0000
+++ /tmp/pyrefly_pr.txt 2026-05-06 00:57:29.342899909 +0000
@@ -5533,9 +5533,9 @@
ERROR Object of class `NoneType` has no attribute `storage_key` [missing-attribute]
--> tests/unit_tests/factories/test_build_from_mapping.py:164:12
ERROR `in` is not supported between `Literal['file']` and `None` [not-iterable]
- --> tests/unit_tests/factories/test_file_factory.py:282:16
+ --> tests/unit_tests/factories/test_file_factory.py:285:16
ERROR `in` is not supported between `Literal['.txt']` and `None` [not-iterable]
- --> tests/unit_tests/factories/test_file_factory.py:283:16
+ --> tests/unit_tests/factories/test_file_factory.py:286:16
ERROR Argument `datetime` is not assignable to parameter `created_at` with type `Decimal | bool | bytes | float | int | str | None` in function `fields.file_fields.FileWithSignedUrl.__init__` [bad-argument-type]
--> tests/unit_tests/fields/test_file_fields.py:55:20
ERROR `dict[str, str | None]` is not assignable to TypedDict key `site` with type `list[dict[str, Any]] | list[dict[str, str]] | str` [bad-typed-dict-key]
|
Contributor
|
rebase the main code, test has been fixed |
…_type for datasource files
`_build_from_datasource_file` first builds `extension = "." + datasource_file.key.split(".")[-1]`
(or `".bin"`), then incorrectly called `standardize_file_type(extension="." + extension, ...)`,
producing `..csv`/`..bin`. The mitigating `lstrip(".")` inside `standardize_file_type` masked
the symptom, but the call shape was wrong and inconsistent with every other builder in this
file (`_build_from_local_file`, `_build_from_remote_url`, `_build_from_tool_file`), all of
which pass `extension` exactly once-prefixed.
Pass the already-prefixed `extension` directly so the helper sees ".csv" instead of "..csv".
Adds two regression tests:
- standardize_file_type receives ".csv" (single-dot) for a keyed datasource file.
- Falls back to ".bin" when the upload key has no dot.
4bff5ec to
1772552
Compare
Contributor
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-05-06 02:55:42.377025645 +0000
+++ /tmp/pyrefly_pr.txt 2026-05-06 02:55:30.632000940 +0000
@@ -5535,9 +5535,9 @@
ERROR Object of class `NoneType` has no attribute `storage_key` [missing-attribute]
--> tests/unit_tests/factories/test_build_from_mapping.py:164:12
ERROR `in` is not supported between `Literal['file']` and `None` [not-iterable]
- --> tests/unit_tests/factories/test_file_factory.py:282:16
+ --> tests/unit_tests/factories/test_file_factory.py:285:16
ERROR `in` is not supported between `Literal['.txt']` and `None` [not-iterable]
- --> tests/unit_tests/factories/test_file_factory.py:283:16
+ --> tests/unit_tests/factories/test_file_factory.py:286:16
ERROR Argument `datetime` is not assignable to parameter `created_at` with type `Decimal | bool | bytes | float | int | str | None` in function `fields.file_fields.FileWithSignedUrl.__init__` [bad-argument-type]
--> tests/unit_tests/fields/test_file_fields.py:55:20
ERROR `dict[str, str | None]` is not assignable to TypedDict key `site` with type `list[dict[str, Any]] | list[dict[str, str]] | str` [bad-typed-dict-key]
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Testing
```
uv run python -m pytest tests/unit_tests/factories/test_file_factory.py::TestBuildFromDatasourceFile -v
```
```
tests/unit_tests/factories/test_file_factory.py::TestBuildFromDatasourceFile::test_extension_passed_without_doubled_dot PASSED [ 50%]
tests/unit_tests/factories/test_file_factory.py::TestBuildFromDatasourceFile::test_extension_falls_back_to_bin_when_key_has_no_dot PASSED [100%]
============================== 2 passed in 0.13s ===============================
```
The first test fails on `main` (asserts the captured argument is `".csv"` but receives `"..csv"`), confirming the regression guard.