diff --git a/idbstubs/special_cases.py b/idbstubs/special_cases.py index c2972cc1..3500736c 100644 --- a/idbstubs/special_cases.py +++ b/idbstubs/special_cases.py @@ -185,6 +185,7 @@ def log_unused() -> None: (0, 1): 'Literal[0, 2, 4]' }, 'panda3d.core.Filename.__init__': {(2, 1): 'StrOrBytesPath'}, + 'panda3d.core.InternalName.make': {(0, 0): 'str'}, 'panda3d.core.IStreamWrapper.__init__': {(0, 1): 'core.istream'}, 'panda3d.core.NodePath.__init__': { (1, 1): 'NodePath[_N]', (3, 1): '_N', (2, 2): '_N' @@ -348,6 +349,7 @@ def log_unused() -> None: }) EXTRA_COERCION: Final = TrackingMap({ 'Filename': {'StrOrBytesPath'}, + 'InternalName': {'str'}, }) diff --git a/src/panda3d-stubs/core/_gobj.pyi b/src/panda3d-stubs/core/_gobj.pyi index a68e10f3..9a7263d8 100644 --- a/src/panda3d-stubs/core/_gobj.pyi +++ b/src/panda3d-stubs/core/_gobj.pyi @@ -496,7 +496,7 @@ class InternalName(TypedWritableReferenceCount): def basename(self) -> str: ... @overload @staticmethod - def make(str) -> InternalName: + def make(str: str) -> InternalName: """`(str)`: These versions are exposed to Python, which have additional logic to map from Python interned strings. @@ -659,7 +659,7 @@ class InternalName(TypedWritableReferenceCount): in which case the nth transform is the nth entry in the table. """ @staticmethod - def get_morph(column: InternalName, slider: str) -> InternalName: + def get_morph(column: InternalName | str, slider: str) -> InternalName: """Returns an InternalName derived from the given base column name and the given slider name, which is the column header for the offset vector that should be applied to the base column name when the named morph slider is @@ -736,7 +736,7 @@ class GeomVertexColumn(GeomEnums): @overload def __init__( self, - name: InternalName, + name: InternalName | str, num_components: int, numeric_type: _GeomEnums_NumericType, contents: _GeomEnums_Contents, @@ -809,7 +809,7 @@ class GeomVertexColumn(GeomEnums): """Returns true if the data store of this column is exactly the same as that of the other, irrespective of name or start position within the record. """ - def set_name(self, name: InternalName) -> None: + def set_name(self, name: InternalName | str) -> None: """Replaces the name of an existing column. This is only legal on an unregistered format (i.e. when constructing the format initially). """ @@ -883,16 +883,20 @@ class GeomVertexArrayFormat(TypedWritableReferenceCount, GeomEnums): def __init__(self, copy: GeomVertexArrayFormat = ...) -> None: ... @overload def __init__( - self, name0: InternalName, num_components0: int, numeric_type0: _GeomEnums_NumericType, contents0: _GeomEnums_Contents + self, + name0: InternalName | str, + num_components0: int, + numeric_type0: _GeomEnums_NumericType, + contents0: _GeomEnums_Contents, ) -> None: ... @overload def __init__( self, - name0: InternalName, + name0: InternalName | str, num_components0: int, numeric_type0: _GeomEnums_NumericType, contents0: _GeomEnums_Contents, - name1: InternalName, + name1: InternalName | str, num_components1: int, numeric_type1: _GeomEnums_NumericType, contents1: _GeomEnums_Contents, @@ -900,15 +904,15 @@ class GeomVertexArrayFormat(TypedWritableReferenceCount, GeomEnums): @overload def __init__( self, - name0: InternalName, + name0: InternalName | str, num_components0: int, numeric_type0: _GeomEnums_NumericType, contents0: _GeomEnums_Contents, - name1: InternalName, + name1: InternalName | str, num_components1: int, numeric_type1: _GeomEnums_NumericType, contents1: _GeomEnums_Contents, - name2: InternalName, + name2: InternalName | str, num_components2: int, numeric_type2: _GeomEnums_NumericType, contents2: _GeomEnums_Contents, @@ -916,19 +920,19 @@ class GeomVertexArrayFormat(TypedWritableReferenceCount, GeomEnums): @overload def __init__( self, - name0: InternalName, + name0: InternalName | str, num_components0: int, numeric_type0: _GeomEnums_NumericType, contents0: _GeomEnums_Contents, - name1: InternalName, + name1: InternalName | str, num_components1: int, numeric_type1: _GeomEnums_NumericType, contents1: _GeomEnums_Contents, - name2: InternalName, + name2: InternalName | str, num_components2: int, numeric_type2: _GeomEnums_NumericType, contents2: _GeomEnums_Contents, - name3: InternalName, + name3: InternalName | str, num_components3: int, numeric_type3: _GeomEnums_NumericType, contents3: _GeomEnums_Contents, @@ -1015,14 +1019,14 @@ class GeomVertexArrayFormat(TypedWritableReferenceCount, GeomEnums): @overload def add_column( self, - name: InternalName, + name: InternalName | str, num_components: int, numeric_type: _GeomEnums_NumericType, contents: _GeomEnums_Contents, start: int = ..., column_alignment: int = ..., ) -> int: ... - def remove_column(self, name: InternalName) -> None: + def remove_column(self, name: InternalName | str) -> None: """Removes the column with the indicated name, if any. This leaves a gap in the byte structure. """ @@ -1043,7 +1047,7 @@ class GeomVertexArrayFormat(TypedWritableReferenceCount, GeomEnums): def get_num_columns(self) -> int: """Returns the number of different columns in the array.""" @overload - def get_column(self, name: InternalName) -> GeomVertexColumn: + def get_column(self, name: InternalName | str) -> GeomVertexColumn: """`(self, name: InternalName)`: Returns the specification with the indicated name, or NULL if the name is not used. @@ -1059,7 +1063,7 @@ class GeomVertexArrayFormat(TypedWritableReferenceCount, GeomEnums): def get_column(self, i: int) -> GeomVertexColumn: ... @overload def get_column(self, start_byte: int, num_bytes: int) -> GeomVertexColumn: ... - def has_column(self, name: InternalName) -> bool: + def has_column(self, name: InternalName | str) -> bool: """Returns true if the array has the named column, false otherwise.""" def is_data_subset_of(self, other: GeomVertexArrayFormat) -> bool: """Returns true if all of the fields in this array format are also present and @@ -1249,7 +1253,7 @@ class GeomVertexFormat(TypedWritableReferenceCount, GeomEnums): all arrays. """ @overload - def get_array_with(self, name: InternalName) -> int: + def get_array_with(self, name: InternalName | str) -> int: """`(self, name: InternalName)`: Returns the index number of the array with the indicated column, or -1 if no arrays contained that name. @@ -1270,7 +1274,7 @@ class GeomVertexFormat(TypedWritableReferenceCount, GeomEnums): @overload def get_array_with(self, i: int) -> int: ... @overload - def get_column(self, name: InternalName) -> GeomVertexColumn: + def get_column(self, name: InternalName | str) -> GeomVertexColumn: """`(self, name: InternalName)`: Returns the specification with the indicated name, or NULL if the name is not used. Use get_array_with() to determine which array this column is @@ -1281,11 +1285,11 @@ class GeomVertexFormat(TypedWritableReferenceCount, GeomEnums): """ @overload def get_column(self, i: int) -> GeomVertexColumn: ... - def has_column(self, name: InternalName) -> bool: + def has_column(self, name: InternalName | str) -> bool: """Returns true if the format has the named column, false otherwise.""" def get_column_name(self, i: int) -> InternalName: """Returns the name of the ith column, across all arrays.""" - def remove_column(self, name: InternalName, keep_empty_array: bool = ...) -> None: + def remove_column(self, name: InternalName | str, keep_empty_array: bool = ...) -> None: """Removes the named column from the format, from whichever array it exists in. If there are other columns remaining in the array, the array is left with a gap where the column used to be; if this was the only column in the @@ -1941,7 +1945,7 @@ class GeomVertexArrayData(CopyOnWriteObject, SimpleLruPage, GeomEnums): Don't call this in a downstream thread unless you don't mind it blowing away other changes you might have recently made in an upstream thread. """ - def has_column(self, name: InternalName) -> bool: + def has_column(self, name: InternalName | str) -> bool: """Returns true if the array has the named column, false otherwise. This is really just a shortcut for asking the same thing from the format. """ @@ -2661,12 +2665,12 @@ class SliderTable(TypedWritableReferenceCount): """Returns the nth slider in the table.""" def get_slider_rows(self, n: int) -> SparseArray: """Returns the set of rows (vertices) governed by the nth slider in the table.""" - def find_sliders(self, name: InternalName) -> SparseArray: + def find_sliders(self, name: InternalName | str) -> SparseArray: """Returns a list of slider indices that represent the list of sliders with the indicated name, or an empty SparseArray if no slider in the table has that name. """ - def has_slider(self, name: InternalName) -> bool: + def has_slider(self, name: InternalName | str) -> bool: """Returns true if the table has at least one slider by the indicated name, false otherwise. """ @@ -2797,7 +2801,7 @@ class GeomVertexData(CopyOnWriteObject, GeomEnums): must have the same number of arrays with the same stride in each one. No checking is performed that the data remains sensible. """ - def has_column(self, name: InternalName) -> bool: + def has_column(self, name: InternalName | str) -> bool: """Returns true if the data has the named column, false otherwise. This is really just a shortcut for asking the same thing from the format. """ @@ -3084,7 +3088,7 @@ class GeomVertexData(CopyOnWriteObject, GeomEnums): @overload def transform_vertices(self, mat: Mat4Like, begin_row: int, end_row: int) -> None: ... def replace_column( - self, name: InternalName, num_components: int, numeric_type: _GeomEnums_NumericType, contents: _GeomEnums_Contents + self, name: InternalName | str, num_components: int, numeric_type: _GeomEnums_NumericType, contents: _GeomEnums_Contents ) -> GeomVertexData: """Returns a new GeomVertexData object, suitable for modification, with the indicated data type replaced with a new table filled with undefined values. @@ -4021,7 +4025,7 @@ class TextureStage(TypedWritableReferenceCount): of multi-texturing. """ @overload - def set_texcoord_name(self, name: InternalName) -> None: + def set_texcoord_name(self, name: InternalName | str) -> None: """Indicate which set of UV's this texture stage will use. Geometry may have any number of associated UV sets, each of which must have a unique name. """ @@ -4943,7 +4947,7 @@ class GeomVertexReader(GeomEnums): @overload def __init__(self, array_data: GeomVertexArrayData, column: int, current_thread: Thread = ...) -> None: ... @overload - def __init__(self, vertex_data: GeomVertexData, name: InternalName, current_thread: Thread = ...) -> None: ... + def __init__(self, vertex_data: GeomVertexData, name: InternalName | str, current_thread: Thread = ...) -> None: ... def assign(self, copy: GeomVertexArrayData | GeomVertexData | GeomVertexReader | Thread) -> GeomVertexReader: ... def get_vertex_data(self) -> GeomVertexData: """Returns the vertex data object that the reader is processing. This may @@ -4980,7 +4984,7 @@ class GeomVertexReader(GeomEnums): def get_force(self) -> bool: """Returns the value of the force flag. See set_force().""" @overload - def set_column(self, name: InternalName) -> bool: + def set_column(self, name: InternalName | str) -> bool: """`(self, name: InternalName)`: Sets up the reader to use the data type with the indicated name. @@ -5248,7 +5252,7 @@ class GeomVertexWriter(GeomEnums): @overload def __init__(self, array_data: GeomVertexArrayData, column: int, current_thread: Thread = ...) -> None: ... @overload - def __init__(self, vertex_data: GeomVertexData, name: InternalName, current_thread: Thread = ...) -> None: ... + def __init__(self, vertex_data: GeomVertexData, name: InternalName | str, current_thread: Thread = ...) -> None: ... def assign(self, copy: GeomVertexArrayData | GeomVertexData | GeomVertexWriter | Thread) -> GeomVertexWriter: ... def get_vertex_data(self) -> GeomVertexData: """Returns the vertex data object that the writer is processing. This may @@ -5273,7 +5277,7 @@ class GeomVertexWriter(GeomEnums): the constructor of this object. """ @overload - def set_column(self, name: InternalName) -> bool: + def set_column(self, name: InternalName | str) -> bool: """`(self, name: InternalName)`: Sets up the writer to use the data type with the indicated name. @@ -5811,7 +5815,7 @@ class GeomVertexRewriter(GeomVertexWriter, GeomVertexReader): # type: ignore[mi @overload def __init__(self, array_data: GeomVertexArrayData, column: int, current_thread: Thread = ...) -> None: ... @overload - def __init__(self, vertex_data: GeomVertexData, name: InternalName, current_thread: Thread = ...) -> None: ... + def __init__(self, vertex_data: GeomVertexData, name: InternalName | str, current_thread: Thread = ...) -> None: ... def upcast_to_GeomVertexWriter(self) -> GeomVertexWriter: ... def upcast_to_GeomVertexReader(self) -> GeomVertexReader: ... def assign(self, copy: GeomVertexArrayData | GeomVertexData | GeomVertexRewriter | Thread) -> GeomVertexRewriter: ... # type: ignore[override] @@ -5833,7 +5837,7 @@ class GeomVertexRewriter(GeomVertexWriter, GeomVertexReader): # type: ignore[mi to use the GeomVertexRewriter directly. """ @overload - def set_column(self, name: InternalName) -> bool: + def set_column(self, name: InternalName | str) -> bool: """`(self, name: InternalName)`: Sets up the rewriter to use the data type with the indicated name. @@ -6887,7 +6891,7 @@ class Texture(TypedWritableReferenceCount, Namable): Returns true on success, false on failure (in which case, the Texture may or may not still be valid). """ - def load_related(self, suffix: InternalName) -> Texture: + def load_related(self, suffix: InternalName | str) -> Texture: """Loads a texture whose filename is derived by concatenating a suffix to the filename of this texture. May return NULL, for example, if this texture doesn't have a filename. diff --git a/src/panda3d-stubs/core/_grutil.pyi b/src/panda3d-stubs/core/_grutil.pyi index 67a93e7e..3a7c9992 100644 --- a/src/panda3d-stubs/core/_grutil.pyi +++ b/src/panda3d-stubs/core/_grutil.pyi @@ -1431,7 +1431,7 @@ class PfmVizzer: """ def get_vis_inverse(self) -> bool: """Returns the vis_inverse flag. See set_vis_inverse().""" - def set_flat_texcoord_name(self, flat_texcoord_name: InternalName) -> None: + def set_flat_texcoord_name(self, flat_texcoord_name: InternalName | str) -> None: """If the flat_texcoord_name is specified, it is the name of an additional vertex column that will be created for the "flat" texture coordinates, i.e. the original 0..1 values that correspond to the 2-D index position of each @@ -1505,7 +1505,7 @@ class PfmVizzer: self, source: _PfmVizzer_ColumnType, target: _PfmVizzer_ColumnType, - name: InternalName, + name: InternalName | str, transform: TransformState = ..., lens: Lens = ..., undist_lut: PfmFile = ..., diff --git a/src/panda3d-stubs/core/_pgraph.pyi b/src/panda3d-stubs/core/_pgraph.pyi index 4658e227..8adaf98b 100644 --- a/src/panda3d-stubs/core/_pgraph.pyi +++ b/src/panda3d-stubs/core/_pgraph.pyi @@ -2780,14 +2780,14 @@ class ShaderInput: @overload def __init__(self, __param0: ShaderInput) -> None: ... @overload - def __init__(self, name: InternalName, priority: int = ...) -> None: ... + def __init__(self, name: InternalName | str, priority: int = ...) -> None: ... @overload - def __init__(self, name: InternalName, value, priority: int = ...) -> None: ... + def __init__(self, name: InternalName | str, value, priority: int = ...) -> None: ... @overload - def __init__(self, name: InternalName, tex: Texture, sampler: SamplerState, priority: int = ...) -> None: ... + def __init__(self, name: InternalName | str, tex: Texture, sampler: SamplerState, priority: int = ...) -> None: ... @overload def __init__( - self, name: InternalName, tex: Texture, read: bool, write: bool, z: int = ..., n: int = ..., priority: int = ... + self, name: InternalName | str, tex: Texture, read: bool, write: bool, z: int = ..., n: int = ..., priority: int = ... ) -> None: ... def __bool__(self) -> bool: ... def __eq__(self, __other: object) -> bool: ... @@ -2829,9 +2829,9 @@ class InternalNameCollection: def __add__(self, other: InternalNameCollection) -> InternalNameCollection: ... def __iter__(self) -> Iterator[InternalName]: ... # Doesn't actually exist def assign(self: Self, copy: Self) -> Self: ... - def add_name(self, name: InternalName) -> None: + def add_name(self, name: InternalName | str) -> None: """Adds a new InternalName to the collection.""" - def remove_name(self, name: InternalName) -> bool: + def remove_name(self, name: InternalName | str) -> bool: """Removes the indicated InternalName from the collection. Returns true if the name was removed, false if it was not a member of the collection. """ @@ -2849,7 +2849,7 @@ class InternalNameCollection: If a InternalName appears multiple times, the first appearance is retained; subsequent appearances are removed. """ - def has_name(self, name: InternalName) -> bool: + def has_name(self, name: InternalName | str) -> bool: """Returns true if the indicated InternalName appears in this collection, false otherwise. """ @@ -4455,26 +4455,26 @@ class NodePath(Generic[_N]): @overload def set_shader_input(self, input: ShaderInput) -> None: ... @overload - def set_shader_input(self, __param0: InternalName, __param1, priority: int = ...) -> None: ... + def set_shader_input(self, __param0: InternalName | str, __param1, priority: int = ...) -> None: ... @overload - def set_shader_input(self, id: InternalName, tex: Texture, sampler: SamplerState, priority: int = ...) -> None: ... + def set_shader_input(self, id: InternalName | str, tex: Texture, sampler: SamplerState, priority: int = ...) -> None: ... @overload def set_shader_input( - self, id: InternalName, n1: float, n2: float, n3: float = ..., n4: float = ..., priority: int = ... + self, id: InternalName | str, n1: float, n2: float, n3: float = ..., n4: float = ..., priority: int = ... ) -> None: ... @overload def set_shader_input( - self, id: InternalName, tex: Texture, read: bool, write: bool, z: int = ..., n: int = ..., priority: int = ... + self, id: InternalName | str, tex: Texture, read: bool, write: bool, z: int = ..., n: int = ..., priority: int = ... ) -> None: ... def set_shader_inputs(self, *args, **kwargs) -> None: ... - def clear_shader_input(self, id: InternalName) -> None: ... + def clear_shader_input(self, id: InternalName | str) -> None: ... def set_instance_count(self, instance_count: int) -> None: """Sets the geometry instance count, or 0 if geometry instancing should be disabled. Do not confuse with instanceTo which only applies to animation instancing. """ def get_shader(self) -> Shader: ... - def get_shader_input(self, id: InternalName) -> ShaderInput: ... + def get_shader_input(self, id: InternalName | str) -> ShaderInput: ... def get_instance_count(self) -> int: """Returns the geometry instance count, or 0 if disabled. See set_instance_count. @@ -4719,7 +4719,7 @@ class NodePath(Generic[_N]): that use the named texture coordinate set, false otherwise. Pass the empty string for the default texture coordinate set. """ - def has_vertex_column(self, name: InternalName) -> bool: + def has_vertex_column(self, name: InternalName | str) -> bool: """Returns true if there are at least some vertices at this node and below that contain a reference to the indicated vertex data column name, false otherwise. @@ -10381,7 +10381,7 @@ class ShaderAttrib(RenderAttrib): def set_shader_input(self, input: ShaderInput) -> RenderAttrib: """Shader Inputs""" @overload - def set_shader_input(self, __param0: InternalName, __param1, priority: int = ...) -> RenderAttrib: ... + def set_shader_input(self, __param0: InternalName | str, __param1, priority: int = ...) -> RenderAttrib: ... def set_shader_inputs(self, *args, **kwargs) -> RenderAttrib: ... def set_instance_count(self, instance_count: int) -> RenderAttrib: """Sets the geometry instance count. Do not confuse this with instanceTo, @@ -10394,7 +10394,7 @@ class ShaderAttrib(RenderAttrib): def clear_all_shader_inputs(self) -> RenderAttrib: """Clears all the shader inputs on the attrib.""" def get_flag(self, flag: int) -> bool: ... - def has_shader_input(self, id: InternalName) -> bool: + def has_shader_input(self, id: InternalName | str) -> bool: """Returns true if there is a ShaderInput of the given name.""" def get_shader(self) -> Shader: """Returns the shader object associated with the node. If get_override @@ -10405,26 +10405,26 @@ class ShaderAttrib(RenderAttrib): """Returns the ShaderInput of the given name. If no such name is found, this function does not return NULL --- it returns the "blank" ShaderInput. """ - def get_shader_input_nodepath(self, id: InternalName) -> NodePath: + def get_shader_input_nodepath(self, id: InternalName | str) -> NodePath: """Returns the ShaderInput as a nodepath. Assertion fails if there is none, or if it is not a nodepath. """ - def get_shader_input_vector(self, id: InternalName) -> LVecBase4: + def get_shader_input_vector(self, id: InternalName | str) -> LVecBase4: """Returns the ShaderInput as a vector. Assertion fails if there is none, or if it is not a vector. """ - def get_shader_input_texture(self, id: InternalName, sampler: SamplerState = ...) -> Texture: + def get_shader_input_texture(self, id: InternalName | str, sampler: SamplerState = ...) -> Texture: """Returns the ShaderInput as a texture. Assertion fails if there is none, or if it is not a texture. If sampler is not NULL, the sampler state to use for this texture is assigned to it. """ - def get_shader_input_matrix(self, id: InternalName, matrix: Mat4Like) -> LMatrix4: + def get_shader_input_matrix(self, id: InternalName | str, matrix: Mat4Like) -> LMatrix4: """Returns the ShaderInput as a matrix. Assertion fails if there is none, or if it is not a matrix or NodePath. """ - def get_shader_input_buffer(self, id: InternalName) -> ShaderBuffer: + def get_shader_input_buffer(self, id: InternalName | str) -> ShaderBuffer: """Returns the ShaderInput as a ShaderBuffer. Assertion fails if there is none, or if it is not a ShaderBuffer. """ @@ -10761,7 +10761,7 @@ class SceneGraphReducer: Returns the number of nodes removed from the graph. """ - def remove_column(self, root: PandaNode, column: InternalName) -> int: + def remove_column(self, root: PandaNode, column: InternalName | str) -> int: """Removes the indicated data column from any GeomVertexDatas found at the indicated root and below. Returns the number of GeomNodes modified. """