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
Fix bug where encoding
setting in .sqlfluff file was not being respected
#3170
Fix bug where encoding
setting in .sqlfluff file was not being respected
#3170
Conversation
@@ -1256,44 +1256,40 @@ def test_encoding(encoding_in, encoding_out): | |||
) | |||
|
|||
|
|||
def test_cli_pass_on_correct_encoding_argument(): |
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.
Replaced two tests that were testing the --encoding
command-line parameter with a single parametrized test which does the same but also tests setting encoding in the .sqlfluff
config file.
@@ -247,7 +247,7 @@ def core_options(f: Callable) -> Callable: | |||
)(f) | |||
f = click.option( | |||
"--encoding", | |||
default="autodetect", | |||
default=None, |
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.
Providing an explicit default value of "autodetect"
was causing any setting in .sqlfluff
to be overridden by the command-line value. (You'll note that elsewhere in this file, command-line options that override .sqlfluff
values already had a default value of None
.)
Codecov Report
@@ Coverage Diff @@
## main #3170 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 166 166
Lines 12341 12341
=========================================
Hits 12341 12341
Continue to review full report at Codecov.
|
("utf-8", "command-line", False), | ||
("utf-8-SIG", "command-line", True), | ||
("utf-8", "config-file", False), | ||
("utf-8-SIG", "config-file", True), |
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.
For completeness we could add the following, as capitalisation seems to be irrelevant:
("utf-8", "command-line", False), | |
("utf-8-SIG", "command-line", True), | |
("utf-8", "config-file", False), | |
("utf-8-SIG", "config-file", True), | |
("utf-8", "command-line", False), | |
("UTF-8", "command-line", False), | |
("utf-8-sig", "command-line", True), | |
("UTF-8-SIG", "command-line", True), | |
("utf-8-SIG", "command-line", True), | |
("utf-8", "config-file", False), | |
("UTF-8", "config-file", False), | |
("utf-8-sig", "config-file", True), | |
("UTF-8-SIG", "config-file", True), | |
("utf-8-SIG", "config-file", True), |
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.
Makes sense, but I think I'll omit it for now, as encoding is something SQLFluff doesn't really process, it mainly relies on the chardet
package and Python built-ins like file, etc.
encoding
setting in .sqlfluff file was not being respected
Brief summary of the change made
Fixes #3157
Are there any other side effects of this change that we should be aware of?
Pull Request checklist
Please confirm you have completed any of the necessary steps below.
Included test cases to demonstrate any code changes, which may be one or more of the following:
.yml
rule test cases intest/fixtures/rules/std_rule_cases
..sql
/.yml
parser test cases intest/fixtures/dialects
(note YML files can be auto generated withtox -e generate-fixture-yml
).test/fixtures/linter/autofix
.Added appropriate documentation for the change.
Created GitHub issues for any relevant followup/future enhancements if appropriate.