Add __slots__ to third-party packages using stubdefaulter (#14619)

This commit is contained in:
Jelle Zijlstra
2025-08-21 15:38:13 -07:00
committed by GitHub
parent 573b57d8da
commit ca44e4c45d
135 changed files with 675 additions and 25 deletions
@@ -8,6 +8,7 @@ Lexer: Incomplete
class TokenStream: ...
class BufferedTokenStream(TokenStream):
__slots__ = ("tokenSource", "tokens", "index", "fetchedEOF")
tokenSource: Incomplete
tokens: Incomplete
index: int
@@ -5,6 +5,7 @@ from antlr4.Token import CommonToken as CommonToken
class TokenFactory: ...
class CommonTokenFactory(TokenFactory):
__slots__ = "copyText"
DEFAULT: Incomplete
copyText: Incomplete
def __init__(self, copyText: bool = False) -> None: ...
@@ -5,6 +5,7 @@ from antlr4.Lexer import Lexer as Lexer
from antlr4.Token import Token as Token
class CommonTokenStream(BufferedTokenStream):
__slots__ = "channel"
channel: Incomplete
def __init__(self, lexer: Lexer, channel: int = 0) -> None: ...
def adjustSeekIndex(self, i: int) -> int: ...
@@ -3,6 +3,7 @@ from _typeshed import Incomplete
from antlr4.InputStream import InputStream as InputStream
class FileStream(InputStream):
__slots__ = "fileName"
fileName: Incomplete
def __init__(self, fileName: str, encoding: str = "ascii", errors: str = "strict") -> None: ...
def readDataFrom(self, fileName: str, encoding: str, errors: str = "strict"): ...
@@ -3,6 +3,7 @@ from _typeshed import Incomplete
from antlr4.Token import Token as Token
class InputStream:
__slots__ = ("name", "strdata", "_index", "data", "_size")
name: str
strdata: Incomplete
data: Incomplete
@@ -1,6 +1,7 @@
from antlr4.Token import Token as Token
class IntervalSet:
__slots__ = ("intervals", "readonly")
intervals: list[range] | None
readonly: bool
def __init__(self) -> None: ...
@@ -19,6 +19,7 @@ from antlr4.RuleContext import RuleContext as RuleContext
from antlr4.Token import Token as Token
class LL1Analyzer:
__slots__ = "atn"
HIT_PRED: Incomplete
atn: Incomplete
def __init__(self, atn: ATN) -> None: ...
@@ -15,6 +15,22 @@ from antlr4.Token import Token as Token
class TokenSource: ...
class Lexer(Recognizer, TokenSource):
__slots__ = (
"_input",
"_output",
"_factory",
"_tokenFactorySourcePair",
"_token",
"_tokenStartCharIndex",
"_tokenStartLine",
"_tokenStartColumn",
"_hitEOF",
"_channel",
"_type",
"_modeStack",
"_mode",
"_text",
)
DEFAULT_MODE: int
MORE: int
SKIP: int
@@ -5,6 +5,7 @@ from antlr4.Lexer import TokenSource as TokenSource
from antlr4.Token import Token as Token
class ListTokenSource(TokenSource):
__slots__ = ("tokens", "sourceName", "pos", "eofToken", "_factory")
tokens: Incomplete
sourceName: Incomplete
pos: int
@@ -20,6 +20,7 @@ from antlr4.tree.ParseTreePatternMatcher import ParseTreePatternMatcher as Parse
from antlr4.tree.Tree import ErrorNode as ErrorNode, ParseTreeListener as ParseTreeListener, TerminalNode as TerminalNode
class TraceListener(ParseTreeListener):
__slots__ = "_parser"
def __init__(self, parser) -> None: ...
def enterEveryRule(self, ctx) -> None: ...
def visitTerminal(self, node) -> None: ...
@@ -27,6 +28,17 @@ class TraceListener(ParseTreeListener):
def exitEveryRule(self, ctx) -> None: ...
class Parser(Recognizer):
__slots__ = (
"_input",
"_output",
"_errHandler",
"_precedenceStack",
"_ctx",
"buildParseTrees",
"_tracer",
"_parseListeners",
"_syntaxErrors",
)
bypassAltsAtnCache: Incomplete
buildParseTrees: bool
def __init__(self, input: TokenStream, output: TextIO = ...) -> None: ...
@@ -18,6 +18,16 @@ from antlr4.PredictionContext import PredictionContextCache as PredictionContext
from antlr4.Token import Token as Token
class ParserInterpreter(Parser):
__slots__ = (
"grammarFileName",
"atn",
"tokenNames",
"ruleNames",
"decisionToDFA",
"sharedContextCache",
"_parentContextStack",
"pushRecursionContextStates",
)
grammarFileName: Incomplete
atn: Incomplete
tokenNames: Incomplete
@@ -13,6 +13,7 @@ from antlr4.tree.Tree import (
)
class ParserRuleContext(RuleContext):
__slots__ = ("children", "start", "stop", "exception")
children: Incomplete
start: Incomplete
stop: Incomplete
@@ -5,6 +5,7 @@ from antlr4.RuleContext import RuleContext as RuleContext
from antlr4.Token import Token as Token
class Recognizer:
__slots__ = ("_listeners", "_interp", "_stateNumber")
tokenTypeMapCache: Incomplete
ruleIndexMapCache: Incomplete
def __init__(self) -> None: ...
@@ -7,6 +7,7 @@ from antlr4.tree.Trees import Trees as Trees
Parser: Incomplete
class RuleContext(RuleNode):
__slots__ = ("parentCtx", "invokingState")
EMPTY: Incomplete
parentCtx: Incomplete
invokingState: Incomplete
@@ -1,6 +1,7 @@
from _typeshed import Incomplete
class Token:
__slots__ = ("source", "type", "channel", "start", "stop", "tokenIndex", "line", "column", "_text")
INVALID_TYPE: int
EPSILON: int
MIN_USER_TOKEN_TYPE: int
@@ -4,6 +4,7 @@ from antlr4.CommonTokenStream import CommonTokenStream as CommonTokenStream
from antlr4.Token import Token as Token
class TokenStreamRewriter:
__slots__ = ("tokens", "programs", "lastRewriteTokenIndexes")
DEFAULT_PROGRAM_NAME: str
PROGRAM_INIT_SIZE: int
MIN_TOKEN_INDEX: int
@@ -34,6 +35,7 @@ class TokenStreamRewriter:
def getText(self, program_name, start: int, stop: int): ...
class RewriteOperation:
__slots__ = ("tokens", "index", "text", "instructionIndex")
tokens: Incomplete
index: Incomplete
text: Incomplete
@@ -48,6 +50,7 @@ class TokenStreamRewriter:
class InsertAfterOp(InsertBeforeOp): ...
class ReplaceOp(RewriteOperation):
__slots__ = "last_index"
last_index: Incomplete
def __init__(self, from_idx, to_idx, tokens, text) -> None: ...
def execute(self, buf): ...
@@ -7,6 +7,18 @@ from antlr4.RuleContext import RuleContext as RuleContext
from antlr4.Token import Token as Token
class ATN:
__slots__ = (
"grammarType",
"maxTokenType",
"states",
"decisionToState",
"ruleToStartState",
"ruleToStopState",
"modeNameToStartState",
"ruleToTokenType",
"lexerActions",
"modeToStartState",
)
INVALID_ALT_NUMBER: int
grammarType: Incomplete
maxTokenType: Incomplete
@@ -6,6 +6,7 @@ from antlr4.atn.SemanticContext import SemanticContext as SemanticContext
from antlr4.PredictionContext import PredictionContext as PredictionContext
class ATNConfig:
__slots__ = ("state", "alt", "context", "semanticContext", "reachesIntoOuterContext", "precedenceFilterSuppressed")
state: Incomplete
alt: Incomplete
context: Incomplete
@@ -26,6 +27,7 @@ class ATNConfig:
def equalsForConfigSet(self, other): ...
class LexerATNConfig(ATNConfig):
__slots__ = ("lexerActionExecutor", "passedThroughNonGreedyDecision")
lexerActionExecutor: Incomplete
passedThroughNonGreedyDecision: Incomplete
def __init__(
@@ -13,6 +13,17 @@ from antlr4.Utils import str_list as str_list
ATNSimulator: Incomplete
class ATNConfigSet:
__slots__ = (
"configLookup",
"fullCtx",
"readonly",
"configs",
"uniqueAlt",
"conflictingAlts",
"hasSemanticContext",
"dipsIntoOuterContext",
"cachedHashCode",
)
configLookup: Incomplete
fullCtx: Incomplete
readonly: bool
@@ -1,6 +1,7 @@
from _typeshed import Incomplete
class ATNDeserializationOptions:
__slots__ = ("readonly", "verifyATN", "generateRuleBypassTransitions")
defaultOptions: Incomplete
readonly: bool
verifyATN: Incomplete
@@ -11,6 +11,7 @@ from antlr4.Token import Token as Token
SERIALIZED_VERSION: int
class ATNDeserializer:
__slots__ = ("deserializationOptions", "data", "pos")
deserializationOptions: Incomplete
def __init__(self, options: ATNDeserializationOptions | None = None) -> None: ...
data: Incomplete
@@ -10,6 +10,7 @@ from antlr4.PredictionContext import (
)
class ATNSimulator:
__slots__ = ("atn", "sharedContextCache", "__dict__")
ERROR: Incomplete
atn: Incomplete
sharedContextCache: Incomplete
@@ -5,6 +5,7 @@ from antlr4.atn.Transition import Transition as Transition
INITIAL_NUM_TRANSITIONS: int
class ATNState:
__slots__ = ("atn", "stateNumber", "stateType", "ruleIndex", "epsilonOnlyTransitions", "transitions", "nextTokenWithinRule")
INVALID_TYPE: int
BASIC: int
RULE_START: int
@@ -39,11 +40,13 @@ class BasicState(ATNState):
def __init__(self) -> None: ...
class DecisionState(ATNState):
__slots__ = ("decision", "nonGreedy")
decision: int
nonGreedy: bool
def __init__(self) -> None: ...
class BlockStartState(DecisionState):
__slots__ = "endState"
endState: Incomplete
def __init__(self) -> None: ...
@@ -52,6 +55,7 @@ class BasicBlockStartState(BlockStartState):
def __init__(self) -> None: ...
class BlockEndState(ATNState):
__slots__ = "startState"
stateType: Incomplete
startState: Incomplete
def __init__(self) -> None: ...
@@ -61,6 +65,7 @@ class RuleStopState(ATNState):
def __init__(self) -> None: ...
class RuleStartState(ATNState):
__slots__ = ("stopState", "isPrecedenceRule")
stateType: Incomplete
stopState: Incomplete
isPrecedenceRule: bool
@@ -71,6 +76,7 @@ class PlusLoopbackState(DecisionState):
def __init__(self) -> None: ...
class PlusBlockStartState(BlockStartState):
__slots__ = "loopBackState"
stateType: Incomplete
loopBackState: Incomplete
def __init__(self) -> None: ...
@@ -84,12 +90,14 @@ class StarLoopbackState(ATNState):
def __init__(self) -> None: ...
class StarLoopEntryState(DecisionState):
__slots__ = ("loopBackState", "isPrecedenceDecision")
stateType: Incomplete
loopBackState: Incomplete
isPrecedenceDecision: Incomplete
def __init__(self) -> None: ...
class LoopEndState(ATNState):
__slots__ = "loopBackState"
stateType: Incomplete
loopBackState: Incomplete
def __init__(self) -> None: ...
@@ -22,6 +22,7 @@ from antlr4.PredictionContext import (
from antlr4.Token import Token as Token
class SimState:
__slots__ = ("index", "line", "column", "dfaState")
def __init__(self) -> None: ...
index: int
line: int
@@ -30,6 +31,7 @@ class SimState:
def reset(self) -> None: ...
class LexerATNSimulator(ATNSimulator):
__slots__ = ("decisionToDFA", "recog", "startIndex", "line", "column", "mode", "DEFAULT_MODE", "MAX_CHAR_VALUE", "prevAccept")
debug: bool
dfa_debug: bool
MIN_DFA_EDGE: int
@@ -14,6 +14,7 @@ class LexerActionType(IntEnum):
TYPE = 7
class LexerAction:
__slots__ = ("actionType", "isPositionDependent")
actionType: Incomplete
isPositionDependent: bool
def __init__(self, action: LexerActionType) -> None: ...
@@ -26,6 +27,7 @@ class LexerSkipAction(LexerAction):
def execute(self, lexer: Lexer): ...
class LexerTypeAction(LexerAction):
__slots__ = "type"
type: Incomplete
def __init__(self, type: int) -> None: ...
def execute(self, lexer: Lexer): ...
@@ -33,6 +35,7 @@ class LexerTypeAction(LexerAction):
def __eq__(self, other): ...
class LexerPushModeAction(LexerAction):
__slots__ = "mode"
mode: Incomplete
def __init__(self, mode: int) -> None: ...
def execute(self, lexer: Lexer): ...
@@ -50,6 +53,7 @@ class LexerMoreAction(LexerAction):
def execute(self, lexer: Lexer): ...
class LexerModeAction(LexerAction):
__slots__ = "mode"
mode: Incomplete
def __init__(self, mode: int) -> None: ...
def execute(self, lexer: Lexer): ...
@@ -57,6 +61,7 @@ class LexerModeAction(LexerAction):
def __eq__(self, other): ...
class LexerCustomAction(LexerAction):
__slots__ = ("ruleIndex", "actionIndex")
ruleIndex: Incomplete
actionIndex: Incomplete
isPositionDependent: bool
@@ -66,6 +71,7 @@ class LexerCustomAction(LexerAction):
def __eq__(self, other): ...
class LexerChannelAction(LexerAction):
__slots__ = "channel"
channel: Incomplete
def __init__(self, channel: int) -> None: ...
def execute(self, lexer: Lexer): ...
@@ -73,6 +79,7 @@ class LexerChannelAction(LexerAction):
def __eq__(self, other): ...
class LexerIndexedCustomAction(LexerAction):
__slots__ = ("offset", "action")
offset: Incomplete
action: Incomplete
isPositionDependent: bool
@@ -4,6 +4,7 @@ from antlr4.atn.LexerAction import LexerAction as LexerAction, LexerIndexedCusto
from antlr4.InputStream import InputStream as InputStream
class LexerActionExecutor:
__slots__ = ("lexerActions", "hashCode")
lexerActions: Incomplete
hashCode: Incomplete
def __init__(self, lexerActions: list[LexerAction] = []) -> None: ...
@@ -34,6 +34,7 @@ from antlr4.Token import Token as Token
from antlr4.Utils import str_list as str_list
class ParserATNSimulator(ATNSimulator):
__slots__ = ("parser", "decisionToDFA", "predictionMode", "_input", "_startIndex", "_outerContext", "_dfa", "mergeCache")
debug: bool
trace_atn_sim: bool
dfa_debug: bool
@@ -15,6 +15,7 @@ def filterPrecedencePredicates(collection: set[SemanticContext]): ...
class EmptySemanticContext(SemanticContext): ...
class Predicate(SemanticContext):
__slots__ = ("ruleIndex", "predIndex", "isCtxDependent")
ruleIndex: Incomplete
predIndex: Incomplete
isCtxDependent: Incomplete
@@ -33,6 +34,7 @@ class PrecedencePredicate(SemanticContext):
def __eq__(self, other): ...
class AND(SemanticContext):
__slots__ = "opnds"
opnds: Incomplete
def __init__(self, a: SemanticContext, b: SemanticContext) -> None: ...
def __eq__(self, other): ...
@@ -41,6 +43,7 @@ class AND(SemanticContext):
def evalPrecedence(self, parser: Recognizer, outerContext: RuleContext): ...
class OR(SemanticContext):
__slots__ = "opnds"
opnds: Incomplete
def __init__(self, a: SemanticContext, b: SemanticContext) -> None: ...
def __eq__(self, other): ...
@@ -4,6 +4,7 @@ from antlr4.atn.ATNState import RuleStartState
from antlr4.IntervalSet import IntervalSet
class Transition:
__slots__ = ("target", "isEpsilon", "label")
EPSILON: int
RANGE: int
RULE: int
@@ -22,6 +23,7 @@ class Transition:
def __init__(self, target) -> None: ...
class AtomTransition(Transition):
__slots__ = ("label_", "serializationType")
label_: Incomplete
label: Incomplete
serializationType: Incomplete
@@ -30,6 +32,7 @@ class AtomTransition(Transition):
def matches(self, symbol: int, minVocabSymbol: int, maxVocabSymbol: int): ...
class RuleTransition(Transition):
__slots__ = ("ruleIndex", "precedence", "followState", "serializationType")
ruleIndex: Incomplete
precedence: Incomplete
followState: Incomplete
@@ -39,6 +42,7 @@ class RuleTransition(Transition):
def matches(self, symbol: int, minVocabSymbol: int, maxVocabSymbol: int): ...
class EpsilonTransition(Transition):
__slots__ = ("serializationType", "outermostPrecedenceReturn")
serializationType: Incomplete
isEpsilon: bool
outermostPrecedenceReturn: Incomplete
@@ -46,6 +50,7 @@ class EpsilonTransition(Transition):
def matches(self, symbol: int, minVocabSymbol: int, maxVocabSymbol: int): ...
class RangeTransition(Transition):
__slots__ = ("serializationType", "start", "stop")
serializationType: Incomplete
start: Incomplete
stop: Incomplete
@@ -58,6 +63,7 @@ class AbstractPredicateTransition(Transition):
def __init__(self, target) -> None: ...
class PredicateTransition(AbstractPredicateTransition):
__slots__ = ("serializationType", "ruleIndex", "predIndex", "isCtxDependent")
serializationType: Incomplete
ruleIndex: Incomplete
predIndex: Incomplete
@@ -68,6 +74,7 @@ class PredicateTransition(AbstractPredicateTransition):
def getPredicate(self): ...
class ActionTransition(Transition):
__slots__ = ("serializationType", "ruleIndex", "actionIndex", "isCtxDependent")
serializationType: Incomplete
ruleIndex: Incomplete
actionIndex: Incomplete
@@ -77,6 +84,7 @@ class ActionTransition(Transition):
def matches(self, symbol: int, minVocabSymbol: int, maxVocabSymbol: int): ...
class SetTransition(Transition):
__slots__ = "serializationType"
serializationType: Incomplete
label: Incomplete
def __init__(self, target, set: IntervalSet) -> None: ...
@@ -88,11 +96,13 @@ class NotSetTransition(SetTransition):
def matches(self, symbol: int, minVocabSymbol: int, maxVocabSymbol: int): ...
class WildcardTransition(Transition):
__slots__ = "serializationType"
serializationType: Incomplete
def __init__(self, target) -> None: ...
def matches(self, symbol: int, minVocabSymbol: int, maxVocabSymbol: int): ...
class PrecedencePredicateTransition(AbstractPredicateTransition):
__slots__ = ("serializationType", "precedence")
serializationType: Incomplete
precedence: Incomplete
isEpsilon: bool
@@ -6,6 +6,7 @@ from antlr4.dfa.DFAState import DFAState as DFAState
from antlr4.error.Errors import IllegalStateException as IllegalStateException
class DFA:
__slots__ = ("atnStartState", "decision", "_states", "s0", "precedenceDfa")
atnStartState: Incomplete
decision: Incomplete
s0: Incomplete
@@ -5,6 +5,7 @@ from antlr4.dfa.DFAState import DFAState as DFAState
from antlr4.Utils import str_list as str_list
class DFASerializer:
__slots__ = ("dfa", "literalNames", "symbolicNames")
dfa: Incomplete
literalNames: list[str] | None
symbolicNames: list[str] | None
@@ -4,11 +4,22 @@ from antlr4.atn.ATNConfigSet import ATNConfigSet as ATNConfigSet
from antlr4.atn.SemanticContext import SemanticContext as SemanticContext
class PredPrediction:
__slots__ = ("alt", "pred")
alt: Incomplete
pred: Incomplete
def __init__(self, pred: SemanticContext, alt: int) -> None: ...
class DFAState:
__slots__ = (
"stateNumber",
"configs",
"edges",
"isAcceptState",
"prediction",
"lexerActionExecutor",
"requiresFullContext",
"predicates",
)
stateNumber: Incomplete
configs: Incomplete
edges: Incomplete
@@ -3,10 +3,12 @@ from _typeshed import Incomplete
class Chunk: ...
class TagChunk(Chunk):
__slots__ = ("tag", "label")
tag: Incomplete
label: Incomplete
def __init__(self, tag: str, label: str | None = None) -> None: ...
class TextChunk(Chunk):
__slots__ = "text"
text: Incomplete
def __init__(self, text: str) -> None: ...
@@ -4,6 +4,7 @@ from antlr4.tree.ParseTreePattern import ParseTreePattern as ParseTreePattern
from antlr4.tree.Tree import ParseTree as ParseTree
class ParseTreeMatch:
__slots__ = ("tree", "pattern", "labels", "mismatchedNode")
tree: Incomplete
pattern: Incomplete
labels: Incomplete
@@ -5,6 +5,7 @@ from antlr4.tree.Tree import ParseTree as ParseTree
from antlr4.xpath.XPathLexer import XPathLexer as XPathLexer
class ParseTreePattern:
__slots__ = ("matcher", "patternRuleIndex", "pattern", "patternTree")
matcher: Incomplete
patternRuleIndex: Incomplete
pattern: Incomplete
@@ -25,6 +25,7 @@ class CannotInvokeStartRule(Exception):
class StartRuleDoesNotConsumeFullPattern(Exception): ...
class ParseTreePatternMatcher:
__slots__ = ("lexer", "parser", "start", "stop", "escape")
lexer: Incomplete
parser: Incomplete
start: str
@@ -3,6 +3,7 @@ from _typeshed import Incomplete
from antlr4.Token import Token as Token
class RuleTagToken(Token):
__slots__ = ("label", "ruleName")
source: Incomplete
type: Incomplete
channel: Incomplete
@@ -3,6 +3,7 @@ from _typeshed import Incomplete
from antlr4.Token import CommonToken as CommonToken
class TokenTagToken(CommonToken):
__slots__ = ("tokenName", "label")
tokenName: Incomplete
label: Incomplete
def __init__(self, tokenName: str, type: int, label: str | None = None) -> None: ...
@@ -27,6 +27,7 @@ class ParseTreeListener:
def exitEveryRule(self, ctx): ...
class TerminalNodeImpl(TerminalNode):
__slots__ = ("parentCtx", "symbol")
parentCtx: Incomplete
symbol: Incomplete
def __init__(self, symbol: Token) -> None: ...