You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iceberg.apache.org by fo...@apache.org on 2023/04/30 20:17:37 UTC

[iceberg] branch master updated: Python: Fix warnings in documentation (#7472)

This is an automated email from the ASF dual-hosted git repository.

fokko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iceberg.git


The following commit(s) were added to refs/heads/master by this push:
     new 9fb90acdac Python: Fix warnings in documentation (#7472)
9fb90acdac is described below

commit 9fb90acdac3e35c40a2882e0d88175416e99f1f8
Author: Brandon George <11...@users.noreply.github.com>
AuthorDate: Sun Apr 30 15:17:28 2023 -0500

    Python: Fix warnings in documentation (#7472)
    
    * updates to remove mkdocs warnings from_bytes()
    
    * updated comments for mkdocs WARNINGS to be removed
    
    * removal of warnings from mkdocs serve --strict
    
    * changes to SortOrder init() added order_id arg
    
    * reverted...
    
    * updated for keyword args vs args order_id
    
    * removed blank line 123 fom sorting.py
    
    * finalizing comments
    
    * Remove spaces
    
    * fixed all mkdocs serve --strict warnings
    
    * fixed trailing whitespace
    
    * updates to comments for mkdocs serve --strict mode
    
    * updates to io/__init__.py for mkdocs warns removal
    
    * updates to remove mkdocs warns from types.py
    
    * updates for schema.py to remove mkdocs warns
    
    * updates to remove mkdoc warns from literals.py
    
    * final mkdocs fixed transforms.py
    
    * request PR changes from code review
    
    * reuest format changes for comments
    
    ---------
    
    Co-authored-by: Fokko Driesprong <fo...@apache.org>
---
 .github/workflows/python-ci-docs.yml     |  2 +-
 python/pyiceberg/expressions/literals.py |  2 +-
 python/pyiceberg/io/__init__.py          | 24 ++++++++++++------------
 python/pyiceberg/io/fsspec.py            | 20 ++++++++++----------
 python/pyiceberg/io/pyarrow.py           | 23 +++++++++++------------
 python/pyiceberg/schema.py               | 18 +++++++++---------
 python/pyiceberg/transforms.py           |  6 +++---
 python/pyiceberg/types.py                | 12 ++++++------
 8 files changed, 53 insertions(+), 54 deletions(-)

diff --git a/.github/workflows/python-ci-docs.yml b/.github/workflows/python-ci-docs.yml
index d9254d30f3..4b732df213 100644
--- a/.github/workflows/python-ci-docs.yml
+++ b/.github/workflows/python-ci-docs.yml
@@ -39,7 +39,7 @@ jobs:
         run: pip install -r requirements.txt
       - name: Build
         working-directory: ./python/mkdocs
-        run: mkdocs build
+        run: mkdocs build --strict
       - name: Copy
         working-directory: ./python/mkdocs
         run: mv ./site /tmp/site
diff --git a/python/pyiceberg/expressions/literals.py b/python/pyiceberg/expressions/literals.py
index ba380cfd67..9aa43531a3 100644
--- a/python/pyiceberg/expressions/literals.py
+++ b/python/pyiceberg/expressions/literals.py
@@ -114,7 +114,7 @@ def literal(value: L) -> Literal[L]:
     A generic Literal factory to construct an Iceberg Literal based on Python primitive data type
 
     Args:
-        value(Python primitive type): the value to be associated with literal
+        value (Python primitive type): the value to be associated with literal
 
     Example:
         from pyiceberg.expressions.literals import literal
diff --git a/python/pyiceberg/io/__init__.py b/python/pyiceberg/io/__init__.py
index b48c0186ac..86213ef911 100644
--- a/python/pyiceberg/io/__init__.py
+++ b/python/pyiceberg/io/__init__.py
@@ -117,11 +117,11 @@ class InputFile(ABC):
     """A base class for InputFile implementations
 
     Args:
-        location(str): A URI or a path to a local file
+        location (str): A URI or a path to a local file
 
     Attributes:
-        location(str): The URI or path to a local file for an InputFile instance
-        exists(bool): Whether the file exists or not
+        location (str): The URI or path to a local file for an InputFile instance
+        exists (bool): Whether the file exists or not
     """
 
     def __init__(self, location: str):
@@ -165,11 +165,11 @@ class OutputFile(ABC):
     """A base class for OutputFile implementations
 
     Args:
-        location(str): A URI or a path to a local file
+        location (str): A URI or a path to a local file
 
     Attributes:
-        location(str): The URI or path to a local file for an OutputFile instance
-        exists(bool): Whether the file exists or not
+        location (str): The URI or path to a local file for an OutputFile instance
+        exists (bool): Whether the file exists or not
     """
 
     def __init__(self, location: str):
@@ -202,8 +202,8 @@ class OutputFile(ABC):
         """This method should return an object that matches the OutputStream protocol.
 
         Args:
-            overwrite(bool): If the file already exists at `self.location`
-            and `overwrite` is False a FileExistsError should be raised
+            overwrite (bool): If the file already exists at `self.location`
+                and `overwrite` is False a FileExistsError should be raised
 
         Returns:
             OutputStream: An object that matches the OutputStream protocol
@@ -227,7 +227,7 @@ class FileIO(ABC):
         """Get an InputFile instance to read bytes from the file at the given location
 
         Args:
-            location(str): A URI or a path to a local file
+            location (str): A URI or a path to a local file
         """
 
     @abstractmethod
@@ -235,7 +235,7 @@ class FileIO(ABC):
         """Get an OutputFile instance to write bytes to the file at the given location
 
         Args:
-            location(str): A URI or a path to a local file
+            location (str): A URI or a path to a local file
         """
 
     @abstractmethod
@@ -243,8 +243,8 @@ class FileIO(ABC):
         """Delete the file at the given path
 
         Args:
-            location(str, InputFile, OutputFile): A URI or a path to a local file--if an InputFile instance or
-            an OutputFile instance is provided, the location attribute for that instance is used as the URI to delete
+            location (Union[str, InputFile, OutputFile]): A URI or a path to a local file--if an InputFile instance or
+                an OutputFile instance is provided, the location attribute for that instance is used as the URI to delete
 
         Raises:
             PermissionError: If the file at location cannot be accessed due to a permission error
diff --git a/python/pyiceberg/io/fsspec.py b/python/pyiceberg/io/fsspec.py
index 12d4b28277..b1859758d2 100644
--- a/python/pyiceberg/io/fsspec.py
+++ b/python/pyiceberg/io/fsspec.py
@@ -148,8 +148,8 @@ class FsspecInputFile(InputFile):
     """An input file implementation for the FsspecFileIO
 
     Args:
-        location(str): A URI to a file location
-        fs(AbstractFileSystem): An fsspec filesystem instance
+        location (str): A URI to a file location
+        fs (AbstractFileSystem): An fsspec filesystem instance
     """
 
     def __init__(self, location: str, fs: AbstractFileSystem):
@@ -192,8 +192,8 @@ class FsspecOutputFile(OutputFile):
     """An output file implementation for the FsspecFileIO
 
     Args:
-        location(str): A URI to a file location
-        fs(AbstractFileSystem): An fsspec filesystem instance
+        location (str): A URI to a file location
+        fs (AbstractFileSystem): An fsspec filesystem instance
     """
 
     def __init__(self, location: str, fs: AbstractFileSystem):
@@ -217,7 +217,7 @@ class FsspecOutputFile(OutputFile):
         """Create an output stream for reading the contents of the file
 
         Args:
-            overwrite(bool): Whether to overwrite the file if it already exists
+            overwrite (bool): Whether to overwrite the file if it already exists
 
         Returns:
             OpenFile: An fsspec compliant file-like object
@@ -253,7 +253,7 @@ class FsspecFileIO(FileIO):
         """Get an FsspecInputFile instance to read bytes from the file at the given location
 
         Args:
-            location(str): A URI or a path to a local file
+            location (str): A URI or a path to a local file
 
         Returns:
             FsspecInputFile: An FsspecInputFile instance for the given location
@@ -266,7 +266,7 @@ class FsspecFileIO(FileIO):
         """Get an FsspecOutputFile instance to write bytes to the file at the given location
 
         Args:
-            location(str): A URI or a path to a local file
+            location (str): A URI or a path to a local file
 
         Returns:
             FsspecOutputFile: An FsspecOutputFile instance for the given location
@@ -279,9 +279,9 @@ class FsspecFileIO(FileIO):
         """Delete the file at the given location
 
         Args:
-            location(str, InputFile, OutputFile): The URI to the file--if an InputFile instance or an
-            OutputFile instance is provided, the location attribute for that instance is used as the location
-            to delete
+            location (Union[str, InputFile, OutputFile]): The URI to the file--if an InputFile instance or an
+                OutputFile instance is provided, the location attribute for that instance is used as the location
+                to delete
         """
         if isinstance(location, (InputFile, OutputFile)):
             str_location = location.location  # Use InputFile or OutputFile location
diff --git a/python/pyiceberg/io/pyarrow.py b/python/pyiceberg/io/pyarrow.py
index ae81733968..56eb338a59 100644
--- a/python/pyiceberg/io/pyarrow.py
+++ b/python/pyiceberg/io/pyarrow.py
@@ -128,7 +128,7 @@ class PyArrowFile(InputFile, OutputFile):
     """A combined InputFile and OutputFile implementation that uses a pyarrow filesystem to generate pyarrow.lib.NativeFile instances
 
     Args:
-        location(str): A URI or a path to a local file
+        location (str): A URI or a path to a local file
 
     Attributes:
         location(str): The URI or path to a local file for a PyArrowFile instance
@@ -222,7 +222,7 @@ class PyArrowFile(InputFile, OutputFile):
         """Creates a writable pyarrow.lib.NativeFile for this PyArrowFile's location
 
         Args:
-            overwrite(bool): Whether to overwrite the file if it already exists
+            overwrite (bool): Whether to overwrite the file if it already exists
 
         Returns:
             pyarrow.lib.NativeFile: A NativeFile instance for the file located at self.location
@@ -289,7 +289,7 @@ class PyArrowFileIO(FileIO):
         """Get a PyArrowFile instance to read bytes from the file at the given location
 
         Args:
-            location(str): A URI or a path to a local file
+            location (str): A URI or a path to a local file
 
         Returns:
             PyArrowFile: A PyArrowFile instance for the given location
@@ -302,7 +302,7 @@ class PyArrowFileIO(FileIO):
         """Get a PyArrowFile instance to write bytes to the file at the given location
 
         Args:
-            location(str): A URI or a path to a local file
+            location (str): A URI or a path to a local file
 
         Returns:
             PyArrowFile: A PyArrowFile instance for the given location
@@ -315,9 +315,8 @@ class PyArrowFileIO(FileIO):
         """Delete the file at the given location
 
         Args:
-            location(str, InputFile, OutputFile): The URI to the file--if an InputFile instance or an
-            OutputFile instance is provided, the location attribute for that instance is used as the location
-            to delete
+            location (Union[str, InputFile, OutputFile]): The URI to the file--if an InputFile instance or an OutputFile instance is provided,
+                the location attribute for that instance is used as the location to delete
 
         Raises:
             FileNotFoundError: When the file at the provided location does not exist
@@ -558,11 +557,11 @@ def project_table(
     """Resolves the right columns based on the identifier
 
     Args:
-        tasks(Iterable[FileScanTask]): A URI or a path to a local file
-        table(Table): The table that's being queried
-        row_filter(BooleanExpression): The expression for filtering rows
-        projected_schema(Schema): The output schema
-        case_sensitive(bool): Case sensitivity when looking up column names
+        tasks (Iterable[FileScanTask]): A URI or a path to a local file
+        table (Table): The table that's being queried
+        row_filter (BooleanExpression): The expression for filtering rows
+        projected_schema (Schema): The output schema
+        case_sensitive (bool): Case sensitivity when looking up column names
 
     Raises:
         ResolveError: When an incompatible query is done
diff --git a/python/pyiceberg/schema.py b/python/pyiceberg/schema.py
index ad18a98f01..ae1f532b68 100644
--- a/python/pyiceberg/schema.py
+++ b/python/pyiceberg/schema.py
@@ -156,7 +156,7 @@ class Schema(IcebergBaseModel):
         """Find a field using a field name or field ID
 
         Args:
-            name_or_id (str | int): Either a field name or a field ID
+            name_or_id (Union[str, int]): Either a field name or a field ID
             case_sensitive (bool, optional): Whether to perform a case-sensitive lookup using a field name. Defaults to True.
 
         Raises:
@@ -184,7 +184,7 @@ class Schema(IcebergBaseModel):
         """Find a field type using a field name or field ID
 
         Args:
-            name_or_id (str | int): Either a field name or a field ID
+            name_or_id (Union[str, int]): Either a field name or a field ID
             case_sensitive (bool, optional): Whether to perform a case-sensitive lookup using a field name. Defaults to True.
 
         Returns:
@@ -692,7 +692,7 @@ class Accessor:
         """Returns the value at self.position in `container`
 
         Args:
-            container(StructProtocol): A container to access at position `self.position`
+            container (StructProtocol): A container to access at position `self.position`
 
         Returns:
             Any: The value at position `self.position` in the container
@@ -714,7 +714,7 @@ def visit(obj: Union[Schema, IcebergType], visitor: SchemaVisitor[T]) -> T:
     The function traverses the schema in post-order fashion
 
     Args:
-        obj(Schema | IcebergType): An instance of a Schema or an IcebergType
+        obj (Union[Schema, IcebergType]): An instance of a Schema or an IcebergType
         visitor (SchemaVisitor[T]): An instance of an implementation of the generic SchemaVisitor base class
 
     Raises:
@@ -783,7 +783,7 @@ def pre_order_visit(obj: Union[Schema, IcebergType], visitor: PreOrderSchemaVisi
     because we don't use the pre-order traversal much.
 
     Args:
-        obj(Schema | IcebergType): An instance of a Schema or an IcebergType
+        obj (Union[Schema, IcebergType]): An instance of a Schema or an IcebergType
         visitor (PreOrderSchemaVisitor[T]): An instance of an implementation of the generic PreOrderSchemaVisitor base class
 
     Raises:
@@ -869,7 +869,7 @@ def index_by_id(schema_or_type: Union[Schema, IcebergType]) -> Dict[int, NestedF
     """Generate an index of field IDs to NestedField instances
 
     Args:
-        schema_or_type (Schema | IcebergType): A schema or type to index
+        schema_or_type (Union[Schema, IcebergType]): A schema or type to index
 
     Returns:
         Dict[int, NestedField]: An index of field IDs to NestedField instances
@@ -975,7 +975,7 @@ def index_by_name(schema_or_type: Union[Schema, IcebergType]) -> Dict[str, int]:
     """Generate an index of field names to field IDs
 
     Args:
-        schema_or_type (Schema | IcebergType): A schema or type to index
+        schema_or_type (Union[Schema, IcebergType]): A schema or type to index
 
     Returns:
         Dict[str, int]: An index of field names to field IDs
@@ -992,7 +992,7 @@ def index_name_by_id(schema_or_type: Union[Schema, IcebergType]) -> Dict[int, st
     """Generate an index of field IDs full field names
 
     Args:
-        schema_or_type (Schema | IcebergType): A schema or type to index
+        schema_or_type (Union[Schema, IcebergType]): A schema or type to index
 
     Returns:
         Dict[str, int]: An index of field IDs to full names
@@ -1071,7 +1071,7 @@ def build_position_accessors(schema_or_type: Union[Schema, IcebergType]) -> Dict
     """Generate an index of field IDs to schema position accessors
 
     Args:
-        schema_or_type (Schema | IcebergType): A schema or type to index
+        schema_or_type (Union[Schema, IcebergType]): A schema or type to index
 
     Returns:
         Dict[int, Accessor]: An index of field IDs to accessors
diff --git a/python/pyiceberg/transforms.py b/python/pyiceberg/transforms.py
index b362cfbf88..34af1258bc 100644
--- a/python/pyiceberg/transforms.py
+++ b/python/pyiceberg/transforms.py
@@ -709,10 +709,10 @@ def _(_type: IcebergType, value: int) -> str:
 class UnknownTransform(Transform[S, T]):
     """A transform that represents when an unknown transform is provided
     Args:
-      source_type (IcebergType): An Iceberg `Type`
       transform (str): A string name of a transform
-    Raises:
-      AttributeError: If the apply method is called.
+
+    Keyword Args:
+      source_type (IcebergType): An Iceberg `Type`
     """
 
     __root__: LiteralType["unknown"] = Field(default="unknown")  # noqa: F821
diff --git a/python/pyiceberg/types.py b/python/pyiceberg/types.py
index e11f6138c9..9b2eb015bc 100644
--- a/python/pyiceberg/types.py
+++ b/python/pyiceberg/types.py
@@ -389,9 +389,9 @@ class IntegerType(PrimitiveType):
 
     Attributes:
         max (int): The maximum allowed value for Integers, inherited from the canonical Iceberg implementation
-          in Java (returns `2147483647`)
+            in Java (returns `2147483647`)
         min (int): The minimum allowed value for Integers, inherited from the canonical Iceberg implementation
-          in Java (returns `-2147483648`)
+            in Java (returns `-2147483648`)
     """
 
     max: ClassVar[int] = 2147483647
@@ -415,9 +415,9 @@ class LongType(PrimitiveType):
 
     Attributes:
         max (int): The maximum allowed value for Longs, inherited from the canonical Iceberg implementation
-          in Java. (returns `9223372036854775807`)
+            in Java. (returns `9223372036854775807`)
         min (int): The minimum allowed value for Longs, inherited from the canonical Iceberg implementation
-          in Java (returns `-9223372036854775808`)
+            in Java (returns `-9223372036854775808`)
     """
 
     max: ClassVar[int] = 9223372036854775807
@@ -439,9 +439,9 @@ class FloatType(PrimitiveType):
 
     Attributes:
         max (float): The maximum allowed value for Floats, inherited from the canonical Iceberg implementation
-          in Java. (returns `3.4028235e38`)
+            in Java. (returns `3.4028235e38`)
         min (float): The minimum allowed value for Floats, inherited from the canonical Iceberg implementation
-          in Java (returns `-3.4028235e38`)
+            in Java (returns `-3.4028235e38`)
     """
 
     max: ClassVar[float] = 3.4028235e38