knit_script.knit_script_warnings.Knit_Script_Warning module
A module containing the base class for Knitting Script warnings.
This module provides the base warning class and specific warning types for the KnitScript programming language. These warnings alert developers to potentially problematic code patterns, configuration issues, and situations that may lead to unexpected behavior without causing program termination. The warning system helps developers write more robust knit script programs by identifying common pitfalls and questionable practices during execution.
- exception Knit_Script_Warning(message)[source]
Bases:
RuntimeWarningBase class for warnings caused by error-prone code in Knit Script.
The Knit_Script_Warning class serves as the foundation for all warning types in the KnitScript programming language. It extends Python’s RuntimeWarning to provide KnitScript-specific warning behavior and consistent message formatting. All specific KnitScript warning types inherit from this class, creating a hierarchical warning system that allows for both specific and general warning handling patterns.
This base class automatically prefixes warning messages with “KnitScript Warning:” to clearly identify KnitScript-related warnings and distinguish them from other system warnings. The warning system is designed to help developers identify potentially problematic code without stopping program execution.
- __init__(message)[source]
Initialize the Knit_Script_Warning.
Creates a new KnitScript warning with the provided message. The message is automatically formatted with a KnitScript warning prefix and newline formatting for consistent warning display.
- Parameters:
message (str) – The warning message to display. This will be prefixed with “KnitScript Warning:” in the final formatted message.
- add_note()
Exception.add_note(note) – add a note to the exception
- args
- with_traceback()
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception Shadow_Variable_Warning(variable_name)[source]
Bases:
Knit_Script_WarningWarning raised when a variable shadows another variable in an outer scope.
This warning is issued when a variable is defined in a local scope that has the same name as a variable in an outer scope, potentially hiding the outer variable and causing confusion. Variable shadowing can lead to unexpected behavior when developers intend to access the outer variable but inadvertently access the inner one instead.
- __init__(variable_name)[source]
Initialize the Shadow_Variable_Warning.
- Parameters:
variable_name (str) – The name of the variable that is shadowing another variable in an outer scope.
- add_note()
Exception.add_note(note) – add a note to the exception
- args
- with_traceback()
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception Shadows_Global_Variable_Warning(variable_name)[source]
Bases:
Shadow_Variable_WarningWarning raised when a variable shadows a global variable.
This specific type of shadow warning is issued when a local variable is defined with the same name as a global variable, potentially hiding the global variable. This is a more specific case of variable shadowing that focuses on global scope conflicts, which can be particularly problematic since global variables are often expected to be accessible throughout the program.
- __init__(variable_name)[source]
Initialize the Shadows_Global_Variable_Warning.
- Parameters:
variable_name (str) – The name of the variable that is shadowing a global variable.
- add_note()
Exception.add_note(note) – add a note to the exception
- args
- with_traceback()
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception Sheet_Beyond_Gauge_Warning(sheet, gauge)[source]
Bases:
Knit_Script_WarningWarning raised when the sheet setting exceeds the current gauge limits.
This warning occurs when attempting to set a sheet number that is outside the valid range for the current gauge configuration. Since sheet numbers must be between 0 and gauge-1, this warning is issued when automatic correction is applied to bring the sheet value back within acceptable bounds.
- __init__(sheet, gauge)[source]
Initialize the Sheet_Beyond_Gauge_Warning.
- Parameters:
sheet (int | Sheet_Identifier) – The sheet value that exceeds the gauge limits and triggered the warning.
gauge (int) – The current gauge setting that defines the valid range for sheet values.
- add_note()
Exception.add_note(note) – add a note to the exception
- args
- with_traceback()
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception Negative_Sheet_Warning(sheet)[source]
Bases:
Knit_Script_WarningWarning raised when the sheet value is negative and reset to 0.
This warning occurs when attempting to set a sheet number that is outside the valid range for the current gauge configuration. Since sheet numbers must be between 0 and gauge-1, this warning is issued when automatic correction is applied to bring the sheet value back within acceptable bounds.
- __init__(sheet)[source]
Initialize the Sheet_Beyond_Gauge_Warning.
- Parameters:
sheet (int | Sheet_Identifier) – The sheet value that exceeds the gauge limits and triggered the warning.
- add_note()
Exception.add_note(note) – add a note to the exception
- args
- with_traceback()
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception Gauge_Value_Warning(gauge)[source]
Bases:
Knit_Script_WarningWarning raised when gauge is set to a non-positive value.
- __init__(gauge)[source]
- Parameters:
gauge (int) – The invalid gauge value that was provided and caused the warning.
- add_note()
Exception.add_note(note) – add a note to the exception
- args
- with_traceback()
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception Cut_Unspecified_Carrier_Warning(cur_carrier_set)[source]
Bases:
Knit_Script_WarningWarning raised when no carrier is specified with a cut operation.
- __init__(cur_carrier_set)[source]
Initialize the Sheet_Beyond_Gauge_Warning.
- Parameters:
cur_carrier_set (Yarn_Carrier_Set | None) – The current carrier that will be cut because no carrier set was specified.
- add_note()
Exception.add_note(note) – add a note to the exception
- args
- with_traceback()
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception Breakpoint_Condition_Error_Ignored_Warning(condition_error, line_number)[source]
Bases:
Knit_Script_WarningWarning raised when a breakpoint condition is ignored.
- __init__(condition_error, line_number)[source]
Initialize the Knit_Script_Warning.
Creates a new KnitScript warning with the provided message. The message is automatically formatted with a KnitScript warning prefix and newline formatting for consistent warning display.
- Parameters:
message (str) – The warning message to display. This will be prefixed with “KnitScript Warning:” in the final formatted message.
- add_note()
Exception.add_note(note) – add a note to the exception
- args
- with_traceback()
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception Repeated_Needle_Warning(needle)[source]
Bases:
Knit_Script_WarningWarning raised when a carriage pass would require passing over the same needle more than once.
This exception prevents machine operations that would attempt to work on the same needle multiple times within a single carriage pass, which is not physically possible on most knitting machines.
- needle
The needle that would be worked on multiple times.
- Type:
Needle
- __init__(needle)[source]
Initialize the Repeated_Needle_Exception.
- Parameters:
needle (Needle) – The needle that would be worked on multiple times.
- add_note()
Exception.add_note(note) – add a note to the exception
- args
- with_traceback()
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception Unspecified_Carrier_Warning(carrier)[source]
Bases:
Knit_Script_WarningWarning raised when no carrier is specified for a directed carriage pass but a valid carrier could be inferred.
- __init__(carrier)[source]
Initialize the Knit_Script_Warning.
Creates a new KnitScript warning with the provided message. The message is automatically formatted with a KnitScript warning prefix and newline formatting for consistent warning display.
- Parameters:
message (str) – The warning message to display. This will be prefixed with “KnitScript Warning:” in the final formatted message.
- add_note()
Exception.add_note(note) – add a note to the exception
- args
- with_traceback()
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.