Fix "Code is unreachable Pylance" warning for NumberPlane#1709
Merged
3b1b merged 1 commit into3b1b:masterfrom Jan 17, 2022
TurkeyBilly:patch-4
Merged
Fix "Code is unreachable Pylance" warning for NumberPlane#17093b1b merged 1 commit into3b1b:masterfrom TurkeyBilly:patch-4
3b1b merged 1 commit into3b1b:masterfrom
TurkeyBilly:patch-4
Conversation
TonyCrane
approved these changes
Jan 17, 2022
TonyCrane
added a commit
that referenced
this pull request
Jan 27, 2022
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.
Motivation
NumberPlaneobject, the code area below will be marked as "unreachable" by Pylance(When I was writing the code)
(In the source code)
Meanwhile, when clicking "show definition" for
get_x_axis()orget_y_axis, it will jumps to abstract methods underCoordinateSystemHow to disable "code is not reachable" warning and greying out the code? I find this feature to be unreliable quite often. microsoft/pylance-release#248 (Reference)
This warning was due to
however without adding an abstract class decorator
(Jumping was due to the fact that
get_x_axis()andget_y_axisare not overrode again underAxesclass)This pull request aims to improve the structure and make it convenient especially for Pylance user writing and tracking codes
Proposed changes
@abstractclassfor two abstract methodsget_axis,get_x_axis,get_y_axis,get_z_axisso that when using these/writing these methods, Pylance and users can track back to re-implemented methods underAxesclass instead ofCoordinateSystemwhere they will find nothing but a raise ExceptionTest
Tested by initializing a Numberline object and no error occurred.