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

BaseSegment.pos_marker is typed as non optional but sometimes set to None #2741

Conversation

barrywhart
Copy link
Member

@barrywhart barrywhart commented Feb 28, 2022

Brief summary of the change made

Fixes #2738

Are there any other side effects of this change that we should be aware of?

Not really. I had to add casts or assert statements to various places in the code. These are making some assumptions explicit which were previously implicit. They don't add bugs, because the code would've previously crashed if these assumptions were invalid. In the long run, it may turn out some of these were bugs, and we'll need to fix them. But for now, we are adding type hints and making things more explicit, which improves maintainability. Overall, that's a good thing, and it helps new contributors not run into type weirdness as the author of #2737 did today.

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 in test/fixtures/rules/std_rule_cases.
    • .sql/.yml parser test cases in test/fixtures/dialects (note YML files can be auto generated with tox -e generate-fixture-yml).
    • Full autofix test cases in test/fixtures/linter/autofix.
    • Other.
  • Added appropriate documentation for the change.

  • Created GitHub issues for any relevant followup/future enhancements if appropriate.

@barrywhart
Copy link
Member Author

@OTooleMichael: I took a look at making pos_marker optional (as it actually is). The changes were not that bad. What do you think?

@barrywhart barrywhart mentioned this pull request Feb 28, 2022
2 tasks
@codecov
Copy link

codecov bot commented Feb 28, 2022

Codecov Report

Merging #2741 (4f24021) into main (db7bd41) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##              main     #2741   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          163       163           
  Lines        12095     12109   +14     
=========================================
+ Hits         12095     12109   +14     
Impacted Files Coverage Δ
src/sqlfluff/core/parser/segments/base.py 100.00% <100.00%> (ø)
src/sqlfluff/core/rules/base.py 100.00% <100.00%> (ø)
...lfluff/core/rules/functional/segment_predicates.py 100.00% <100.00%> (ø)
src/sqlfluff/rules/L003.py 100.00% <100.00%> (ø)
src/sqlfluff/rules/L016.py 100.00% <100.00%> (ø)
src/sqlfluff/rules/L018.py 100.00% <100.00%> (ø)
src/sqlfluff/rules/L046.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update db7bd41...4f24021. Read the comment docs.

@barrywhart barrywhart merged commit 7a204dd into sqlfluff:main Feb 28, 2022
@tunetheweb tunetheweb changed the title BaseSegment.pos_marker is typed as non optional but sometimes set to … BaseSegment.pos_marker is typed as non optional but sometimes set to None Feb 28, 2022
@tunetheweb tunetheweb changed the title BaseSegment.pos_marker is typed as non optional but sometimes set to None BaseSegment.pos_marker is typed as non optional but sometimes set to None Mar 6, 2022
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.

BaseSegment.pos_marker is typed as non optional but sometimes set to None
2 participants