Skip to content

Commit

Permalink
style[eve]: remove unused imports and fix typos (#1748)
Browse files Browse the repository at this point in the history
Small cleanup PR in the eve framework:

- Removes a stale `.gitignore` file. As far as I understood from the git
history, earlier versions of this codebase had many `.gitignore` files
in many places. Looks like this one is a leftover from a previous time.
- Remove a couple of stale includes. The language server marked them as
unused and since tests still pass, I guess we really don't need them
anymore.
- Fixed a couple of typos in comments
- Fixed two typos in the github PR template
  • Loading branch information
romanc authored Dec 2, 2024
1 parent 99c5300 commit 6f49699
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 43 deletions.
4 changes: 2 additions & 2 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Delete this comment and add a proper description of the changes contained in thi
- test: Adding missing tests or correcting existing tests
<scope>: cartesian | eve | next | storage
# ONLY if changes are limited to a specific subsytem
# ONLY if changes are limited to a specific subsystem
- PR Description:
Expand All @@ -27,7 +27,7 @@ Delete this comment and add a proper description of the changes contained in thi
## Requirements

- [ ] All fixes and/or new features come with corresponding tests.
- [ ] Important design decisions have been documented in the approriate ADR inside the [docs/development/ADRs/](docs/development/ADRs/Index.md) folder.
- [ ] Important design decisions have been documented in the appropriate ADR inside the [docs/development/ADRs/](docs/development/ADRs/Index.md) folder.

If this PR contains code authored by new contributors please make sure:

Expand Down
1 change: 0 additions & 1 deletion src/gt4py/eve/.gitignore

This file was deleted.

14 changes: 2 additions & 12 deletions src/gt4py/eve/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
"""

from __future__ import annotations # isort:skip

from __future__ import annotations

from .concepts import (
AnnexManager,
Expand Down Expand Up @@ -89,15 +88,6 @@
"SymbolRef",
"VType",
"register_annex_user",
"# datamodels" "Coerced",
"DataModel",
"FrozenModel",
"GenericDataModel",
"Unchecked",
"concretize",
"datamodel",
"field",
"frozenmodel",
# datamodels
"Coerced",
"DataModel",
Expand All @@ -122,7 +112,7 @@
"pre_walk_values",
"walk_items",
"walk_values",
"# type_definition",
# type_definitions
"NOTHING",
"ConstrainedStr",
"Enum",
Expand Down
6 changes: 3 additions & 3 deletions src/gt4py/eve/codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ def __str__(self) -> str:
class Template(Protocol):
"""Protocol (abstract base class) defining the Template interface.
Direct subclassess of this base class only need to implement the
Direct subclasses of this base class only need to implement the
abstract methods to adapt different template engines to this
interface.
Expand Down Expand Up @@ -654,8 +654,8 @@ def apply( # redefinition of symbol
Args:
root: An IR node.
node_templates (optiona): see :class:`NodeDumper`.
dump_function (optiona): see :class:`NodeDumper`.
node_templates (optional): see :class:`NodeDumper`.
dump_function (optional): see :class:`NodeDumper`.
``**kwargs`` (optional): custom extra parameters forwarded to `visit_NODE_TYPE_NAME()`.
Returns:
Expand Down
4 changes: 2 additions & 2 deletions src/gt4py/eve/datamodels/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
Data Models can be considered as enhanced `attrs <https://www.attrs.org>`_
/ `dataclasses <https://docs.python.org/3/library/dataclasses.html>`_ providing
additional features like automatic run-time type validation. Values assigned to fields
at initialization can be validated with automatic type checkings using the
at initialization can be validated with automatic type checking using the
field type definition. Custom field validation methods can also be added with
the :func:`validator` decorator, and global instance validation methods with
:func:`root_validator`.
Expand All @@ -33,7 +33,7 @@
1. ``__init__()``.
a. If a custom ``__init__`` already exists in the class, it will not be overwritten.
It is your responsability to call ``__auto_init__`` from there to obtain
It is your responsibility to call ``__auto_init__`` from there to obtain
the described behavior.
b. If there is not custom ``__init__``, the one generated by datamodels
will be called first.
Expand Down
16 changes: 8 additions & 8 deletions src/gt4py/eve/datamodels/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@


try:
# For perfomance reasons, try to use cytoolz when possible (using cython)
# For performance reasons, try to use cytoolz when possible (using cython)
import cytoolz as toolz
except ModuleNotFoundError:
# Fall back to pure Python toolz
Expand Down Expand Up @@ -270,7 +270,7 @@ def datamodel(


@overload
def datamodel( # redefinion of unused symbol
def datamodel( # redefinition of unused symbol
cls: Type[_T],
/,
*,
Expand All @@ -289,7 +289,7 @@ def datamodel( # redefinion of unused symbol


# TODO(egparedes): Use @dataclass_transform(eq_default=True, field_specifiers=("field",))
def datamodel( # redefinion of unused symbol
def datamodel( # redefinition of unused symbol
cls: Optional[Type[_T]] = None,
/,
*,
Expand Down Expand Up @@ -867,7 +867,7 @@ def _substitute_typevars(

def _make_counting_attr_from_attribute(
field_attrib: Attribute, *, include_type: bool = False, **kwargs: Any
) -> Any: # attr.s lies a bit in some typing definitons
) -> Any: # attr.s lies a bit in some typing definitions
args = [
"default",
"validator",
Expand Down Expand Up @@ -965,7 +965,7 @@ def _type_converter(value: Any) -> _T:
return value if isinstance(value, type_annotation) else type_annotation(value)
except Exception as error:
raise TypeError(
f"Error during coertion of given value '{value}' for field '{name}'."
f"Error during coercion of given value '{value}' for field '{name}'."
) from error

return _type_converter
Expand Down Expand Up @@ -996,7 +996,7 @@ def _type_converter(value: Any) -> _T:
return _make_type_converter(origin_type, name)

raise exceptions.EveTypeError(
f"Automatic type coertion for {type_annotation} types is not supported."
f"Automatic type coercion for {type_annotation} types is not supported."
)


Expand Down Expand Up @@ -1085,7 +1085,7 @@ def _make_datamodel(
)

else:
# Create field converter if automatic coertion is enabled
# Create field converter if automatic coercion is enabled
converter: TypeConverter = cast(
TypeConverter,
_make_type_converter(type_hint, qualified_field_name) if coerce_field else None,
Expand All @@ -1099,7 +1099,7 @@ def _make_datamodel(
if isinstance(attr_value_in_cls, _KNOWN_MUTABLE_TYPES):
warnings.warn(
f"'{attr_value_in_cls.__class__.__name__}' value used as default in '{cls.__name__}.{key}'.\n"
"Mutable types should not defbe normally used as field defaults (use 'default_factory' instead).",
"Mutable types should not be used as field defaults (use 'default_factory' instead).",
stacklevel=_stacklevel_offset + 2,
)
setattr(
Expand Down
4 changes: 0 additions & 4 deletions src/gt4py/eve/extended_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,8 @@

from __future__ import annotations

import abc as _abc
import array as _array
import collections.abc as _collections_abc
import ctypes as _ctypes
import dataclasses as _dataclasses
import enum as _enum
import functools as _functools
import inspect as _inspect
import mmap as _mmap
Expand Down
8 changes: 0 additions & 8 deletions src/gt4py/eve/trees.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,6 @@
from .type_definitions import Enum


try:
# For performance reasons, try to use cytoolz when possible (using cython)
import cytoolz as toolz
except ModuleNotFoundError:
# Fall back to pure Python toolz
import toolz # noqa: F401 [unused-import]


TreeKey = Union[int, str]


Expand Down
2 changes: 1 addition & 1 deletion src/gt4py/eve/type_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ def __call__(
# ...
#
# Since this can be an arbitrary type (not something regular like a collection) there is
# no way to check if the type parameter is verifed in the actual instance.
# no way to check if the type parameter is verified in the actual instance.
# The only check can be done at run-time is to verify that the value is an instance of
# the original type, completely ignoring the annotation. Ideally, the static type checker
# can do a better job to try figure out if the type parameter is ok ...
Expand Down
2 changes: 1 addition & 1 deletion src/gt4py/eve/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@


try:
# For perfomance reasons, try to use cytoolz when possible (using cython)
# For performance reasons, try to use cytoolz when possible (using cython)
import cytoolz as toolz
except ModuleNotFoundError:
# Fall back to pure Python toolz
Expand Down
2 changes: 1 addition & 1 deletion src/gt4py/next/ffront/decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ def __call__(self, *args: Any, offset_provider: common.OffsetProvider, **kwargs:
if self.backend is None:
warnings.warn(
UserWarning(
f"Field View Program '{self.definition_stage.definition.__name__}': Using Python execution, consider selecting a perfomance backend."
f"Field View Program '{self.definition_stage.definition.__name__}': Using Python execution, consider selecting a performance backend."
),
stacklevel=2,
)
Expand Down

0 comments on commit 6f49699

Please sign in to comment.