Skip to content

Commit

Permalink
Small improvements and fixes to docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Viicos committed Oct 1, 2024
1 parent d36c35d commit 6b883e5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 4 additions & 2 deletions docs/source/usage/creating_operators.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ This method is responsible for

- typechecking the children::

from jsonlogic.typechecking import TypecheckContext
from jsonlogic.typechecking import TypecheckContext, get_type
from jsonlogic.json_schema import from_value
from jsonlogic.json_schema.types import BooleanType, UnsupportedOperation
from jsonlogic.json_schema.types import AnyType, BooleanType, UnsupportedOperation

class GreaterThan(Operator):
...
Expand Down Expand Up @@ -94,6 +94,8 @@ This method is responsible for
"not_comparable",
self
)
# Usually, you will want to return "AnyType" if typechecking failed:
return AnyType()

The :class:`~jsonlogic.typechecking.TypecheckContext` object is used to emit diagnostics
and access the JSON Schema of the data provided when using :func:`~jsonlogic.typechecking.typecheck`.
Expand Down
6 changes: 2 additions & 4 deletions docs/source/usage/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@ if necessary. The underlying expression can be accessed:
>>> expr.expression
{
'>': [
JSONLogicExpression(expression={
'var': [JSONLogicExpression(expression='my_int')] # "my_int" argument as a list
}),
JSONLogicExpression(expression=2)
JSONLogicExpression(expression={'var': ['my_int']}), # "my_int" argument as a list
2
]
}
Expand Down
4 changes: 2 additions & 2 deletions src/jsonlogic/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
JSON: TypeAlias = "JSONPrimitive | JSONArray | JSONObject"

JSONLogicPrimitive: TypeAlias = "JSONPrimitive | list[JSONLogicPrimitive]"
"""A JSON Logic primitive is recursively defined as either a JSON primitive or a list of JSON Logic primitives.
"""A JSON Logic primitive is recursively defined either as a JSON primitive or a list of JSON Logic primitives.
Such primitives are only considered when dealing with operator arguments:
Expand All @@ -36,7 +36,7 @@
"""

OperatorArgument: TypeAlias = "Operator | JSONLogicPrimitive | list[OperatorArgument]"
"""An operator argument is recursively defined a JSON Logic primitive, an operator or a list of operator arguments.
"""An operator argument is recursively defined either as a JSON Logic primitive, an operator or a list of operator arguments.

Check failure on line 39 in src/jsonlogic/typing.py

View workflow job for this annotation

GitHub Actions / Check code linting with Ruff

Ruff (E501)

src/jsonlogic/typing.py:39:121: E501 Line too long (125 > 120)
.. code-block:: json
Expand Down

0 comments on commit 6b883e5

Please sign in to comment.