Skip to content

Commit

Permalink
[#3561] improvement(client-python): Fix redefined-builtin Pylint rule…
Browse files Browse the repository at this point in the history
… for client-python (#3568)

<!--
1. Title: [#<issue>] <type>(<scope>): <subject>
   Examples:
     - "[#123] feat(operator): support xxx"
     - "[#233] fix: check null before access result in xxx"
     - "[MINOR] refactor: fix typo in variable name"
     - "[MINOR] docs: fix typo in README"
     - "[#255] test: fix flaky test NameOfTheTest"
   Reference: https://www.conventionalcommits.org/en/v1.0.0/
2. If the PR is unfinished, please mark this PR as draft.
-->

### What changes were proposed in this pull request?

* Replace varaible names `type` and `property`, which is Python
functions and keywords, with more readable and custom variable names

### Why are the changes needed?

Fix: #3561 

### Does this PR introduce _any_ user-facing change?

No

### How was this patch tested?

`./gradlew clients:client-python:test`

Co-authored-by: noidname01 <55401762+noidname01@users.noreply.github.com>
Co-authored-by: TimWang <tim.wang@pranaq.com>
  • Loading branch information
3 people authored May 27, 2024
1 parent b97b122 commit 0fa0401
Show file tree
Hide file tree
Showing 19 changed files with 108 additions and 93 deletions.
20 changes: 10 additions & 10 deletions clients/client-python/gravitino/api/catalog_change.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,29 +37,29 @@ def update_comment(new_comment):
return CatalogChange.UpdateCatalogComment(new_comment)

@staticmethod
def set_property(property, value):
def set_property(catalog_property, value):
"""Creates a new catalog change to set the property and value for the catalog.
Args:
property: The property name to set.
catalog_property: The property name to set.
value: The value to set the property to.
Returns:
The catalog change.
"""
return CatalogChange.SetProperty(property, value)
return CatalogChange.SetProperty(catalog_property, value)

@staticmethod
def remove_property(property):
def remove_property(catalog_property):
"""Creates a new catalog change to remove a property from the catalog.
Args:
property: The property name to remove.
catalog_property: The property name to remove.
Returns:
The catalog change.
"""
return CatalogChange.RemoveProperty(property)
return CatalogChange.RemoveProperty(catalog_property)

class RenameCatalog:
"""A catalog change to rename the catalog."""
Expand Down Expand Up @@ -156,8 +156,8 @@ def __str__(self):
class SetProperty:
"""A catalog change to set the property and value for the catalog."""

def __init__(self, property, value):
self.property = property
def __init__(self, catalog_property, value):
self.property = catalog_property
self.value = value

def property(self):
Expand Down Expand Up @@ -211,8 +211,8 @@ def __str__(self):
class RemoveProperty:
"""A catalog change to remove a property from the catalog."""

def __init__(self, property):
self._property = property
def __init__(self, catalog_property):
self._property = catalog_property

def get_property(self):
"""Retrieves the name of the property to be removed from the catalog.
Expand Down
20 changes: 10 additions & 10 deletions clients/client-python/gravitino/api/fileset_change.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,29 +39,29 @@ def update_comment(new_comment):
return FilesetChange.UpdateFilesetComment(new_comment)

@staticmethod
def set_property(property, value):
def set_property(fileset_property, value):
"""Creates a new fileset change to set the property and value for the fileset.
Args:
property: The property name to set.
fileset_property: The property name to set.
value: The value to set the property to.
Returns:
The fileset change.
"""
return FilesetChange.SetProperty(property, value)
return FilesetChange.SetProperty(fileset_property, value)

@staticmethod
def remove_property(property):
def remove_property(fileset_property):
"""Creates a new fileset change to remove a property from the fileset.
Args:
property: The property name to remove.
fileset_property: The property name to remove.
Returns:
The fileset change.
"""
return FilesetChange.RemoveProperty(property)
return FilesetChange.RemoveProperty(fileset_property)

class RenameFileset:
"""A fileset change to rename the fileset."""
Expand Down Expand Up @@ -165,8 +165,8 @@ class SetProperty:
_property: str = field(metadata=config(field_name="property"))
_value: str = field(metadata=config(field_name="value"))

def __init__(self, property: str, value: str):
self._property = property
def __init__(self, fileset_property: str, value: str):
self._property = fileset_property
self._value = value

def property(self):
Expand Down Expand Up @@ -222,8 +222,8 @@ class RemoveProperty:

_property: str = field(metadata=config(field_name="property"))

def __init__(self, property: str):
self._property = property
def __init__(self, fileset_property: str):
self._property = fileset_property

def property(self):
"""Retrieves the name of the property to be removed from the fileset.
Expand Down
12 changes: 6 additions & 6 deletions clients/client-python/gravitino/api/metalake_change.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,29 +39,29 @@ def update_comment(new_comment: str) -> "MetalakeChange.UpdateMetalakeComment":
return MetalakeChange.UpdateMetalakeComment(new_comment)

@staticmethod
def set_property(property: str, value: str) -> "SetProperty":
def set_property(metalake_property: str, value: str) -> "SetProperty":
"""Creates a new metalake change to set a property and value pair for the metalake.
Args:
property: The property name to set.
metalake_property: The property name to set.
value: The value to set the property to.
Returns:
The metalake change.
"""
return MetalakeChange.SetProperty(property, value)
return MetalakeChange.SetProperty(metalake_property, value)

@staticmethod
def remove_property(property: str) -> "RemoveProperty":
def remove_property(metalake_property: str) -> "RemoveProperty":
"""Creates a new metalake change to remove a property from the metalake.
Args:
property: The property name to remove.
metalake_property: The property name to remove.
Returns:
The metalake change.
"""
return MetalakeChange.RemoveProperty(property)
return MetalakeChange.RemoveProperty(metalake_property)

@dataclass(frozen=True)
class RenameMetalake:
Expand Down
20 changes: 10 additions & 10 deletions clients/client-python/gravitino/api/schema_change.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,38 +13,38 @@ class SchemaChange(ABC):
"""NamespaceChange class to set the property and value pairs for the namespace."""

@staticmethod
def set_property(property: str, value: str):
def set_property(schema_property: str, value: str):
"""SchemaChange class to set the property and value pairs for the schema.
Args:
property: The property name to set.
schema_property: The property name to set.
value: The value to set the property to.
Returns:
The SchemaChange object.
"""
return SchemaChange.SetProperty(property, value)
return SchemaChange.SetProperty(schema_property, value)

@staticmethod
def remove_property(property: str):
def remove_property(schema_property: str):
"""SchemaChange class to remove a property from the schema.
Args:
property: The property name to remove.
schema_property: The property name to remove.
Returns:
The SchemaChange object.
"""
return SchemaChange.RemoveProperty(property)
return SchemaChange.RemoveProperty(schema_property)

class SetProperty:
"""SchemaChange class to set the property and value pairs for the schema."""

_property: str = field(metadata=config(field_name="property"))
_value: str = field(metadata=config(field_name="value"))

def __init__(self, property: str, value: str):
self._property = property
def __init__(self, schema_property: str, value: str):
self._property = schema_property
self._value = value

def property(self):
Expand Down Expand Up @@ -100,8 +100,8 @@ class RemoveProperty:

_property: str = field(metadata=config(field_name="property"))

def __init__(self, property: str):
self._property = property
def __init__(self, schema_property: str):
self._property = schema_property

def property(self):
"""Retrieves the name of the property to be removed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class BaseSchemaCatalog(CatalogDTO, SupportsSchemas):
def __init__(
self,
name: str = None,
type: Catalog.Type = Catalog.Type.UNSUPPORTED,
catalog_type: Catalog.Type = Catalog.Type.UNSUPPORTED,
provider: str = None,
comment: str = None,
properties: Dict[str, str] = None,
Expand All @@ -47,7 +47,7 @@ def __init__(
):
super().__init__(
_name=name,
_type=type,
_type=catalog_type,
_provider=provider,
_comment=comment,
_properties=properties,
Expand Down
12 changes: 7 additions & 5 deletions clients/client-python/gravitino/catalog/fileset_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,17 @@ class FilesetCatalog(BaseSchemaCatalog):
def __init__(
self,
name: str = None,
type: Catalog.Type = Catalog.Type.UNSUPPORTED,
catalog_type: Catalog.Type = Catalog.Type.UNSUPPORTED,
provider: str = None,
comment: str = None,
properties: Dict[str, str] = None,
audit: AuditDTO = None,
rest_client: HTTPClient = None,
):

super().__init__(name, type, provider, comment, properties, audit, rest_client)
super().__init__(
name, catalog_type, provider, comment, properties, audit, rest_client
)

def as_fileset_catalog(self):
return self
Expand Down Expand Up @@ -92,7 +94,7 @@ def create_fileset(
self,
ident: NameIdentifier,
comment: str,
type: Fileset.Type,
fileset_type: Fileset.Type,
storage_location: str,
properties: Dict[str, str],
) -> Fileset:
Expand All @@ -106,7 +108,7 @@ def create_fileset(
Args:
ident: A fileset identifier.
comment: The comment of the fileset.
type: The type of the fileset.
fileset_type: The type of the fileset.
storage_location: The storage location of the fileset.
properties: The properties of the fileset.
Expand All @@ -122,7 +124,7 @@ def create_fileset(
req = FilesetCreateRequest(
name=ident.name(),
comment=comment,
type=type,
fileset_type=fileset_type,
storage_location=storage_location,
properties=properties,
)
Expand Down
4 changes: 2 additions & 2 deletions clients/client-python/gravitino/client/gravitino_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ def load_catalog(self, ident: NameIdentifier) -> Catalog:
def create_catalog(
self,
ident: NameIdentifier,
type: Catalog.Type,
catalog_type: Catalog.Type,
provider: str,
comment: str,
properties: Dict[str, str],
) -> Catalog:
return self.get_metalake().create_catalog(
ident, type, provider, comment, properties
ident, catalog_type, provider, comment, properties
)

def alter_catalog(self, ident: NameIdentifier, *changes: CatalogChange):
Expand Down
8 changes: 4 additions & 4 deletions clients/client-python/gravitino/client/gravitino_metalake.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,16 +122,16 @@ def load_catalog(self, ident: NameIdentifier) -> Catalog:
def create_catalog(
self,
ident: NameIdentifier,
type: Catalog.Type,
catalog_type: Catalog.Type,
provider: str,
comment: str,
properties: Dict[str, str],
) -> Catalog:
"""Create a new catalog with specified identifier, type, comment and properties.
"""Create a new catalog with specified identifier, catalog type, comment and properties.
Args:
ident: The identifier of the catalog.
type: The type of the catalog.
catalog_type: The type of the catalog.
provider: The provider of the catalog.
comment: The comment of the catalog.
properties: The properties of the catalog.
Expand All @@ -147,7 +147,7 @@ def create_catalog(

catalog_create_request = CatalogCreateRequest(
name=ident.name(),
type=type,
catalog_type=catalog_type,
provider=provider,
comment=comment,
properties=properties,
Expand Down
4 changes: 2 additions & 2 deletions clients/client-python/gravitino/dto/catalog_dto.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ class CatalogDTO(Catalog):
def builder(
self,
name: str = None,
type: Catalog.Type = Catalog.Type.UNSUPPORTED,
catalog_type: Catalog.Type = Catalog.Type.UNSUPPORTED,
provider: str = None,
comment: str = None,
properties: Dict[str, str] = None,
audit: AuditDTO = None,
):
self._name = name
self._type = type
self._type = catalog_type
self._provider = provider
self._comment = comment
self._properties = properties
Expand Down
2 changes: 1 addition & 1 deletion clients/client-python/gravitino/dto/dto_converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def to_catalog(catalog: CatalogDTO, client: HTTPClient):
if catalog.type() == Catalog.Type.FILESET:
return FilesetCatalog(
name=catalog.name(),
type=catalog.type(),
catalog_type=catalog.type(),
provider=catalog.provider(),
comment=catalog.comment(),
properties=catalog.properties(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ class CatalogCreateRequest(RESTRequest):
def __init__(
self,
name: str = None,
type: Catalog.Type = Catalog.Type.UNSUPPORTED,
catalog_type: Catalog.Type = Catalog.Type.UNSUPPORTED,
provider: str = None,
comment: str = None,
properties: Dict[str, str] = None,
):
self._name = name
self._type = type
self._type = catalog_type
self._provider = provider
self._comment = comment
self._properties = properties
Expand All @@ -45,7 +45,9 @@ def validate(self):
IllegalArgumentException if name or type are not set.
"""
assert self._name is not None, '"name" field is required and cannot be empty'
assert self._type is not None, '"type" field is required and cannot be empty'
assert (
self._type is not None
), '"catalog_type" field is required and cannot be empty'
assert (
self._provider is not None
), '"provider" field is required and cannot be empty'
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
class CatalogUpdateRequestBase(RESTRequest):
_type: str = field(metadata=config(field_name="@type"))

def __init__(self, type: str):
self._type = type
def __init__(self, action_type: str):
self._type = action_type

@abstractmethod
def catalog_change(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ def __init__(
self,
name: str,
comment: Optional[str] = None,
type: Fileset.Type = None,
fileset_type: Fileset.Type = None,
storage_location: Optional[str] = None,
properties: Optional[Dict[str, str]] = None,
):
self._name = name
self._comment = comment
self._type = type
self._type = fileset_type
self._storage_location = storage_location
self._properties = properties

Expand Down
Loading

0 comments on commit 0fa0401

Please sign in to comment.