# packages

pkgId: 79f32269a3f1aa049c79ca14f650dcced8ff08f6699b5d2cd43c1eb1d4979ffb
name: python-databrickstools
arch: src
version: 0.3.2
epoch: 0
release: 1
summary: A simple commandline application to manage databricks resources.
url: https://github.com/rhdzmota/databrickstools-cli
rpm_license: LICENSE.md
rpm_group: Unspecified
rpm_buildhost: localhost
location_href: Packages/python-databrickstools-0.3.2-1.src.rpm
checksum_type: sha256
description:
  A simple commandline application to keep in sync between databricks and your local filesystem. This project uses the databricks [workspace api](https://docs.databricks.com/dev-tools/api/latest/workspace.html).

  Key features:
  * List and MkDir commands.
  * Download databricks notebooks as HTML, Jupyter, or Source format.
  * Upload file from your filesystem (source format) to create/overwrite databricks notebooks.
  * Automatically transform markdown files to source!
      * Using markdown syntax instead of source is more convenient.
      * Use codeblocks to change between languages (e.g. `python`, `scala`, `sql`, `sh`).
      * Integrate local development and execution with databricks notebooks.

  ```commandline
  $ databrickstools ls --path /Shared
  ```

  ```commandline
  $ databrickstools upload markdown \
      --from-path exploration.md \
      --to-path /Shared/merchants/exploration
  ```



  Install via `pip`:

  ```commandline
  $ pip install databrickstools
  ```

  Or clone the repository and install the commandline application!

  1. Clone: `git clone https://github.com/rhdzmota/databrickstools-cli`
  1. Install: `pip install -e databrickstools-cli`

  **Note**: you'll need python 3.6 or greater.

  Create the `.env` file containing your environment variables.

  1. Create `.env` following the example `.env.example`:
      * `cp .env.example .env`
  1. Load the variables into the environment:
      *  `export $(cat .env | xargs)`

  **Note**: the `.env` file can be on any place of your machine. The commandline application just needs those variables to be present on the environment.

  Test with a simple command:

  ```commandline
  $ databrickstools ls --path /Shared
  ```



  Assume you have a file named `exploration.md` with the following markdown content:

  ````text


  This is a file containing the initial EDA work.



  ```python
  import pandas as pd
  from sqlalchemy import create_engine

  connection_string = "..."
  engine = create_engine(connection_string)
  ```



  Consider the following invalid merchant data:

  ```python
  SQL_INVALID_MERCHANTS = "SELECT * FROM merchants WHERE invalid = 1"

  df = pd.read_sql(query, engine)
  df.head()
  ```

  Location distribution:

  ```python
  df.groupby("state").size().to_frame()
  ```
  ...

  ````

  You could use [rmarkdown + reticulate](https://rstudio.github.io/reticulate/articles/r_markdown.html) for local development and execution of that report. And then use `databrickstools` to deploy and transform this markdown file into a databricks notebook!

  ```commandline
  $ databrickstools upload markdown \
      --from-path exploration.md \
      --to-path /Shared/merchants/exploration \
      --base-language python \
      --overwrite
  ```



  The CLI contains `groups` or `commands`. A `command` is a method call that received zero or more arguments. A `group` contains one or more `commands` with common functionality.

  Available groups:

  * `download`
  * `upload`





  List the databricks resources for a give path.

  ````commandline
  $ databrickstools ls --path <value>
  ````

  Where:

  `--path` (string)
  > Path to folder inside databricks.

  Example:

  ```text
  $ databrickstools ls --path /Shared
  ```



  Create a directory on databricks.

  ````commandline
  $ databrickstools mkdir --path <value>
  ````

  Where:

  `--path` (string)
  > Path to folder inside databricks.

  Example:

  ```text
  $ databrickstools mkdir --path /Shared/temp
  ```





  Download a given file from databricks!

  ````commandline
  $ databrickstools download file \
      --from-path <value> \
      --to-path <value> \
      --file-format <value>
  ````

  Where:

  `--from-path` (string)
  > Path to file inside databricks.

  `--to-path` (string)
  > Path in local machine.

  `--file-format` (string)
  > Format used to download file.
  > Default: DATABRICKSTOOLS_DEFAULT_FORMAT

  Example:

  ```text
  databrickstools download file \
      --from-path /Shared/example \
      --to-path example \
      --file-format SOURCE
  ```



  Download a notebook as an HTML file.

  ````commandline
  $ databrickstools download html \
      --from-path <value> \
      --to-path <value>
  ````

  Where:

  `--from-path` (string)
  > Path to file inside databricks.

  `--to-path` (string)
  > Path in local machine.

  Example:

  ```text
  $ databrickstools download html \
      --from-path /Shared/example \
      --to-path example.html
  ```



  Download a notebook as a Jupyter file. Only works for python-based notebooks.

  ````commandline
  $ databrickstools download ipynb \
      --from-path <value> \
      --to-path <value>
  ````

  Where:

  `--from-path` (string)
  > Path to file inside databricks.

  `--to-path` (string)
  > Path in local machine.

  Example:

  ```text
  $ databrickstools download ipynb \
      --from-path /Shared/example \
      --to-path example.ipynb
  ```



  Download a notebook as a source file. This can be either a `.py` file for Python or a `.sc` file for Scala.

  ````commandline
  $ databrickstools download source \
      --from-path <value> \
      --to-path <value>
  ````

  Where:

  `--from-path` (string)
  > Path to file inside databricks.

  `--to-path` (string)
  > Path in local machine.


  Example:

  ```text
  $ databrickstools download source \
      --from-path /Shared/example \
      --to-path example.py
  ```





  Upload a markdown file to databricks as a notebook.

  ````commandline
  $ databrickstools upload markdown \
      --from-path <value> \
      --to-path <value> \
      --base-language <value> \
      --overwrite
  ````

  Where:

  `--from-path` (string)
  > Path to `file.md` in your local machine.

  `--to-path` (string)
  > Path to notebook on databricks.

  `--base-language` (string)
  > The markdown might contain multiple languages, but we'll need to define (or know) the base language of the notebook. If not present, the CLI will try to infer the base language by looking into the file-ending or fallback to: `DATABRICKSTOOLS_DEFAULT_LANGUAGE`.

  `--overwrite` (flag)
  > If present, the new file will overwrite the current one on databricks.

  Example:

  ```text
  $ databrickstools markdown \
      --from-path markdown-file.md \
      --to-path /Shared/test \
      --overwrite
  ```



  Same as `markdown` but with the `SOURCE` format.



  To get the most out of markdown please consider taking a look into:
  * [Tut](https://tpolecat.github.io/tut/)
  * [Pandoc](https://pandoc.org/)
  * [RMarkdown](https://rmarkdown.rstudio.com/lesson-1.html)
  * [Reticulate](https://rstudio.github.io/reticulate/articles/r_markdown.html)


pkgId: 3d1734a724fd8f60c123c2d128e7e4f859551506f9038da464603ec06404f999
name: python-databroker
arch: src
version: 1.2.5
epoch: 0
release: 1
summary: Unification of NSLS-II data sources
url: https://github.com/NSLS-II/databroker
rpm_license: BSD (3-clause)
rpm_group: Unspecified
rpm_buildhost: localhost
location_href: Packages/python-databroker-1.2.5-1.src.rpm
checksum_type: sha256
description:
  PyPI           ``pip install databroker``
  Conda          ``pip install -c nsls2forge databroker``
  Source code    https://github.com/bluesky/databroker


pkgId: 8428060393c22a5b3884c193bd2252e9b1f93ec2bad637495f3fcb6080d7af14
name: python-databutton
arch: src
version: 0.38.18
epoch: 0
release: 1
summary: The CLI for databutton.com
url: https://pypi.org/project/databutton/
rpm_license: Databutton
rpm_group: Unspecified
rpm_buildhost: localhost
location_href: Packages/python-databutton-0.38.18-1.src.rpm
checksum_type: sha256
description:
  [![semantic-release: angular](https://img.shields.io/badge/semantic--release-angular-e10079?logo=semantic-release)](https://github.com/semantic-release/semantic-release)
  [![PyPI version fury.io](https://badge.fury.io/py/databutton.svg)](https://pypi.python.org/pypi/databutton/)
  [![PyPI download week](https://img.shields.io/pypi/dw/databutton.svg)](https://pypi.python.org/pypi/databutton/)
  ![release](https://github.com/databutton/databutton-cli/actions/workflows/release.yaml/badge.svg)




  The CLI for building and deploying databutton projects



  ```bash
  Usage: databutton [OPTIONS] COMMAND [ARGS]...

  Options:
    -v, --verbose  Enable verbose logging
    --help         Show this message and exit.

  Commands:
    build    Build the project, built components will be found in .databutton
    create   Create a Databutton project in the provided project-directory
    deploy   Deploy your project to Databutton
    docs     Launches https://docs.databutton.com
    init     Creates a new project in Databutton and writes to databutton.json
    login    Login to Databutton
    logout   Removes all Databutton login info
    serve    Starts a web server for production.
    start    Run the Databutton development server
    version  Get the library version.
    whoami   Shows the logged in user
  ```




  This project uses poetry, so if you haven't already;

  `pip install poetry`



  `poetry install`



  `poetry run pytest -s`


  `make lint``

  All these are being run in a github action on pull requests and the main branch.



  To test in another package, you can simply

  `pip install -e .` assuming you're in this folder. If not, replace the `.` with the path to the `databutton-cli` folder.



  * **Databutton** - *Initial work* - [github](https://github.com/databutton)



  All rights reserved.


pkgId: 1f3f7cc8e46034bcf09f582b459751eb5099878d3ff643f8f299df8330d14841
name: python-databytes
arch: src
version: 1.3
epoch: 0
release: 1
url: https://pypi.org/project/databytes/
rpm_group: Unspecified
rpm_buildhost: localhost
location_href: Packages/python-databytes-1.3-1.src.rpm
checksum_type: sha256
summary:
  A class based binary structure to serialize/deserialize binary data (using python struct under the hood).

description:
  [![PyPI version](https://badge.fury.io/py/databytes.svg)](https://pypi.org/project/databytes/)
  [![CI](https://github.com/twidi/databytes/actions/workflows/lint-and-tests.yml/badge.svg?branch=main)](https://github.com/twidi/databytes/actions/workflows/ci.yml)

  A Python library providing a class-based approach to serialize and deserialize binary data, built on top of Python's `struct` module. DataBytes makes it easy to work with binary structures, shared memory, and memory-mapped files in a type-safe and object-oriented way.



  - Class-based binary structure definitions
  - Type-safe field declarations
  - Support for nested structures and arrays
  - Use standard python binary packing and unpacking via the `struct` package
  - Support for Python 3.10+



  You can install `databytes` from [PyPI](https://pypi.org/project/databytes/):

  ```bash
  pip install databytes
  ```



  ```python
  from databytes import BinaryStruct
  from databytes import types as t

  class Point(BinaryStruct):
      name: t.string[12]  # fixed-length string of 12 chars
      x: t.uint16
      y: t.uint16

  class Rectangle(BinaryStruct):
      top_left: Point
      bottom_right: Point
      area: t.uint32
      selected_points: Point[2]   # array of 2 points


  assert Rectangle._nb_bytes == 68  # (12+4) for each point + 4 for area


  buffer = bytearray(Rectangle._nb_bytes)

  rect = Rectangle(buffer)


  rect.top_left.name = "Top Left"
  rect.top_left.x = 0
  rect.top_left.y = 0
  rect.bottom_right.name = "Bottom Right"
  rect.bottom_right.x = 10
  rect.bottom_right.y = 10
  rect.area = 100
  rect.selected_points[0].name = "Selected 1"
  rect.selected_points[0].x = 1
  rect.selected_points[0].y = 2
  rect.selected_points[1].name = "Selected 2"
  rect.selected_points[1].x = 3
  rect.selected_points[1].y = 4


  print(buffer)



  rect2 = Rectangle(buffer)
  assert rect2.top_left.name == "Top Left"
  assert rect2.top_left.x == 0
  assert rect2.top_left.y == 0
  assert rect2.bottom_right.name == "Bottom Right"
  assert rect2.bottom_right.x == 10
  assert rect2.bottom_right.y == 10
  assert rect2.area == 100
  assert rect2.selected_points[0].name == "Selected 1"
  assert rect2.selected_points[0].x == 1
  assert rect2.selected_points[0].y == 2
  assert rect2.selected_points[1].name == "Selected 2"
  assert rect2.selected_points[1].x == 3
  assert rect2.selected_points[1].y == 4

  ```




  - **Binary Structures**: Define your data structures using Python classes that inherit from `BinaryStruct`
  - **Typing**: Field are declared using type hints
  - **Memory Efficiency**: Direct memory access without unnecessary copies
  - **Shared Memory**: Easy integration with multiprocessing using shared memory buffers
  - **Extensibility**: Create custom field types by extending the base types



  - Python >= 3.10
  - typing-extensions
  - numpy  (only used to create the `Buffer` type alias 😑 )

  Optional dependencies:
  - rich (for enhanced display capabilities)





  As some types have the same name as builtins, the best way to import them is to use `from databytes import types as t` and use the `t.` prefix:

  ```python
  from databytes import BinaryStruct
  from databytes import types as t

  class Data(BinaryStruct):
      field: t.uint16
  ```

  - `uint8` / `ubyte` (1 byte, coalesce to python int)
  - `int8` / `byte` (1 byte, coalesce to python int)
  - `uint16` / `ushort` (2 bytes, coalesce to python int)
  - `int16` / `short` (2 bytes, coalesce to python int)
  - `uint32` (4 bytes, coalesce to python int)
  - `int32` (4 bytes, coalesce to python int)
  - `uint64` (8 bytes, coalesce to python int)
  - `int64` (8 bytes, coalesce to python int)
  - `float32` / `float` (4 bytes, coalesce to python float)
  - `float64` / `double` (8 bytes, coalesce to python float)
  - `char`  (1 byte, coalesce to python bytes)
  - `string` (fixed-length string, automatically padded with nulls, coalesce to python str)



  You can use as a field another struct:

  ```python
  from databytes import BinaryStruct
  from databytes import types as t

  class Point(BinaryStruct):
      x: t.uint16
      y: t.uint16

  class Rectangle(BinaryStruct):
      top_left: Point
      bottom_right: Point

  buffer = bytearray(Rectangle._nb_bytes)
  rect = Rectangle(buffer)
  rect.top_left.x = 0
  rect.top_left.y = 0
  rect.bottom_right.x = 10
  rect.bottom_right.y = 10
  ```

  *WARNING*: It's actually not possible to set the values of a sub-struct directly without using the attributes. It's due to the fact that the sub-structs instances are tied to their parent buffer, with the correct offset.

  ```python
  point_buffer  = bytearray(Point._nb_bytes)
  point = Point(point_buffer)
  point.x = 5
  point.y = 5
  rect.bottom_right = point


  rect2 = Rectangle(buffer)
  assert rect2.bottom_right.x == 10
  assert rect2.bottom_right.y == 10
  ```



  Basic and custom types can be used in arrays of any dimension:

  ```python
  from databytes import BinaryStruct
  from databytes import types as t

  class Point(BinaryStruct):
      x: t.uint16
      y: t.uint16

  class Rectangle(BinaryStruct):
      corners: Point[2]  # array of 2 points
      matrix_2dim: Point[2, 3]  # matrix of 3x2 points
      matrix_3dim: Point[2, 3, 4]  # matrix of 4x3x2 points

  ```

  *WARNING*: The dimensions are defined in reverse order: `Point[2, 3, 4]` is a list of 4 lists of 3 lists of 2 points

  *WARNING*: It's actually not possible to set the arrays instances directly without using concrete slicing and attributes. It's due to the fact that the sub-structs instances are tied to their parent buffer, with the correct offset.

  ```python
  class Point(BinaryStruct):
      x: t.uint16
      y: t.uint16

  class Rectangle(BinaryStruct):
      corners: Point[2]  # array of 2 points

  point1_buffer  = bytearray(Point._nb_bytes)
  point2_buffer  = bytearray(Point._nb_bytes)
  point1 = Point(point1_buffer)
  point1.x = 5
  point1.y = 5
  point2 = Point(point2_buffer)
  point2.x = 10
  point2.y = 10

  buffer = bytearray(Rectangle._nb_bytes)
  rect = Rectangle(buffer)

  rect.corners[0] = point1
  rect.corners[1] = point2

  rect.corners = [point1, point2]

  rect.corners[0].x = 5  # you can use `= point1.x`
  rect.corners[0].y = 5
  rect.corners[1].x = 10
  rect.corners[1].y = 10
  ```



  By default a string is a string of 1 character. To defined the max length, define the length as the first dimension:

  ```python
  from databytes import BinaryStruct
  from databytes import types as t

  class Person(BinaryStruct):
      name: t.string[10]  # fixed-length string of 10 chars
  ```

  When retrieving the value, you'll have a real string, not a list of characters. If the string is shorter than the allocated space, it will be null-padded in the buffer but retrieved as a real string without the nulls.

  To define an array of strings, add more dimensions:

  ```python
  from databytes import BinaryStruct
  from databytes import types as t

  class Person(BinaryStruct):
      name: t.string[10]  # fixed-length string of 10 chars
      aliases: t.string[10, 2]  # array of 2 strings of 10 chars
  ```





  - `BinaryStruct` is the base class for all structures (`from databytes import BinaryStruct`)
  - `types` module contains all available types (`from databytes import types as t`)
  - a `BinaryStruct` instance is created taking a buffer as argument (`buffer = bytearray(Rectangle._nb_bytes); rect = Rectangle(buffer)`) and an optional offset for the start of the buffer to use

  ```python
  from databytes import BinaryStruct
  from databytes import types as t

  class Data(BinaryStruct):
      field: t.uint16

  buffer = bytearray(1000)


  data = Data(buffer, 100)
  ```



  We defined the `Buffer` type alias like this:

  ```python
  Buffer: TypeAlias = bytes | bytearray | memoryview | mmap.mmap | array.array | ctypes.Array | np.ndarray
  ```

  Not that all buffers are not writeable (like `bytes`, immutable `memoryview`s, immutable numpy arrays).

  If you have another buffer type that we should support, please tell us.

  You can use any buffer as long as:
  - it works with `pack_info` and `unpack_from` from the python `struct` module
  - it has a `__len__` method (we use it to ensure at init time that the buffer is big enough)

  (of course, if it's not in our `Buffer` type alias, mypy won't be happy and you'll have to handle it)



  To not pollute the namespace, extra fields are prefixed with `_`:

  - `_nb_bytes` (class var): number of bytes used by the structure (including sub-structs)
  - `_struct_format` (class var): the format, using the python `struct` module format, of the whole structure (just for information)
  - `_endianness` (class var): the endianness of the structure (see below for more details)
  - `_buffer` (instance var): the buffer used by the structure (the buffer passed to the constructor, will be the same for the main struct and all sub-structs)
  - `_offset` (instance var): the offset of this specific structure in the buffer

  You can define your own fields for your own purpose, as only the fields defined in `BinaryStruct` using the `types` module or sub structs inheriting from `BinaryStruct` are handled by the library:

  ```python
  from databytes import BinaryStruct
  from databytes import types as t

  class Data(BinaryStruct):
      field: t.uint16
      my_field: str  # will not be handled by the library

      def __init__(self, my_field: str, buffer: Buffer, offset: int = 0) -> None:
          super().__init__(buffer, offset)
          self.my_field = my_field
  ```



  The endianess of a struct can be defined in two ways:

  - When defining the class by setting the `_endianness` class var:

  ```python
  from databytes import BinaryStruct
  from databytes import types as t, Endianness

  class Data(BinaryStruct):
      _endianness = Endianness.LITTLE
      field: t.uint16
  ```

  - When instantiating the struct with the `endianness` argument (in this case the value will override the class value for this instance):

  ```python
  from databytes import BinaryStruct
  from databytes import types as t, Endianness

  class Data(BinaryStruct):
      _endianness = Endianness.BIG  # will be ignored so it's not necessary to add it
      field: t.uint16

  data = Data(bytearray(1000), endianness=Endianness.LITTLE)
  ```

  `Endianness` is an enum defined in `databytes.types` with the following values:

  - `Endianness.NATIVE` (default): the endianness of the system
  - `Endianness.LITTLE`
  - `Endianness.BIG`
  - `Endianness.NETWORK` (alias for `Endianness.BIG`)


  The default value is forced to `Endianness.NATIVE` and can be changed by setting the `DATABYTES_ENDIANNESS` environment variable (before the `databytes` library is loaded) to `LITTLE`, `BIG`, `NETWORK` (alias for `BIG`) or `NATIVE` (the actual default).

  The `_endianness` of a sub-struct defined on its class will be ignored: all sub-struts automatically inherit the endianness of their parent struct.


  ```python
  from databytes import BinaryStruct
  from databytes import types as t, Endianness

  class Child(BinaryStruct):
      _endianness = Endianness.BIG
      value: t.uint16

  class Data1(BinaryStruct):
      _endianness = Endianness.LITTLE
      child: Child

  class Data2(BinaryStruct):
      child: Child

  buffer = bytearray(2)

  child_alone = Child(buffer)
  child_alone.value = 2
  assert buffer == b"\x00\x02"  # child alone uses big endian from Child class endianness

  data1 = Data1(buffer)
  data1.child.value = 3
  assert buffer == b"\x03\x00"  # child uses little endian from Data1 class endianness

  data2 = Data2(buffer, endianness=Endianness.LITTLE)
  data2.child.value = 4
  assert buffer == b"\x04\x00"  # child uses little endian from Data2 instance endianness

  ```




  It's possible to use the same structure on different buffers:

  ```python
  from databytes import BinaryStruct
  from databytes import types as t

  class Data(BinaryStruct):
      field: t.uint16

  buffer1 = bytearray(1000)
  buffer2 = bytearray(1000)
  buffer3 = bytearray(1000)


  data = Data(buffer1, 100)


  data.attach_buffer(buffer2)


  data.attach_buffer(buffer3, 50)

  ```




  You can copy a full struct (or a sub-struct) from another one using the `fill_from` method:

  ```python
  from databytes import BinaryStruct
  from databytes import types as t

  class Child(BinaryStruct):
      field1: t.uint16
      field2: t.string[5]

  class Data(BinaryStruct):
      field: t.uint16
      children: Child[2]

  buffer1 = bytearray(1000)

  data1 = Data(buffer1)
  data1.field = 1
  data1.children[0].field1 = 2
  data1.children[0].field2 = "Hello"
  data1.children[1].field1 = 3
  data1.children[1].field2 = "World"


  buffer2 = bytearray(1000)
  data2 = Data(buffer2)
  data2.fill_from(data1)

  assert data2.field == 1
  assert data2.children[0].field1 == 2
  assert data2.children[0].field2 == "Hello"
  assert data2.children[1].field1 == 3
  assert data2.children[1].field2 == "World"


  buffer3 = bytearray(1000)
  data3 = Data(buffer3)
  data3.children[1].fill_from(data1.children[0])

  assert data3.children[1].field1 == 2
  assert data3.children[1].field2 == "Hello"

  ```



  The `to_dict()` method allows you to convert a `BinaryStruct` instance and all its fields into a Python dictionary. This is particularly useful when you need to work with the data in a more standard Python format or when you want to serialize the data.

  Example:
  ```python
  from databytes import BinaryStruct
  from databytes import types as t


  class Child(BinaryStruct):
      field1: t.int32
      field2: t.string[5]

  class Parent(BinaryStruct):
      value: t.int32
      children: Child[2]  # Array of 2 Child structures
      matrix: t.uint8[2, 3]  # Array of 3 rows of 2 int


  buffer = bytearray(data._nb_bytes)
  data = Parent(buffer)

  data.value = 42
  data.children[0].field1 = 1
  data.children[0].field2 = "Hello"
  data.children[1].field1 = 2
  data.children[1].field2 = "World"
  data.matrix = [[1, 2], [3, 4], [5, 6]]

  data2 = Parent(buffer)


  assert  data2.to_dict() == {
      "value": 42,
      "children": [
          {"field1": 1, "field2": "Hello"},
          {"field1": 2, "field2": "World"}
      ],
      "matrix": [[1, 2], [3, 4], [5, 6]]
  }
  ```



  The `fill_from_dict` method allows you to populate a structure from a Python dictionary. This is particularly useful when working with JSON data or when you want to initialize a structure with multiple values at once.

  ```python
  from databytes import BinaryStruct
  from databytes import types as t

  class Point(BinaryStruct):
      x: t.uint16
      y: t.uint16

  class Line(BinaryStruct):
      start: Point
      end: Point
      color: t.string[10]


  buffer = bytearray(Line._nb_bytes)
  line = Line(buffer)


  line.fill_from_dict({
      "start": {"x": 10, "y": 20},
      "end": {"x": 30, "y": 40},
      "color": "red"
  })


  line.fill_from_dict({"color": "blue"})  # Only updates the color


  line.fill_from_dict({"start": {"x": 0, "y": 0}}, clear_unset=True)

  ```

  The method works with any level of nesting and with arrays:

  ```python
  class Matrix(BinaryStruct):
      values: t.uint16[2, 3]  # 2x3 matrix
      name: t.string[10]

  buffer = bytearray(Matrix._nb_bytes)
  matrix = Matrix(buffer)

  matrix.fill_from_dict({
      "values": [[1, 2, 3], [4, 5, 6]],
      "name": "test"
  })
  ```

  Note that even if you can skip keys, you cannot pass partial arrays. Arrays given in the dict must have the exact same dimensions as the ones defined in the structure.



  The `clear_buffer()` method allows you to clear the buffer, by filling the space occuped by the structure, starting at the offset it was initialized with, with NULL bytes, for the whole space used by its fields and sub-structs.



  When using shared memory for example, the buffer must be freed before freeing the shared memory. To do that, use the `free_buffer` method:

  ```python
  from databytes import BinaryStruct
  from databytes import types as t

  class Data(BinaryStruct):
      field: t.uint16

  shm = SharedMemory(create=True, size=1000)
  buffer = shm.buf

  data: Data | None = None
  try:
      data = Data(buffer)
      data.value = 2
      data.text = "World"

      

  finally:
      if data is not None:
          data.free_buffer()
      shm.close()
      shm.unlink()
  ```

  Of course, here `data` cannot be used anymore unless you call `attach_buffer` on it with another buffer.





  You can get the layout of a structure with the `get_layout_info` function from `databytes.utils`:

  ```python
  from databytes import BinaryStruct
  from databytes import types as t
  from databytes.utils import get_layout_info

  class Point(BinaryStruct):
      x: t.uint16
      y: t.uint16

  class Rectangle(BinaryStruct):
      corners: Point[2]  # array of 2 points

  get_layout_info(Rectangle)
  ```

  Will give you:

  ```python
  StructLayoutInfo(
      name='Rectangle',
      struct_class=<class '__main__.Rectangle'>,
      endianness=<Endianness.NATIVE: '='>,
      byte_order=<Endianness.LITTLE: '<'>,
      struct_format='HHHH',
      nb_bytes=8,
      offset=0,
      fields={
          'corners': FieldLayoutInfo(
              name='corners',
              offset=0,
              nb_bytes=8,
              struct_format='HHHH',
              nb_items=2,
              dimensions=(2,),
              python_type=<class '__main__.Point'>,
              python_full_type=list[__main__.Point],
              is_sub_struct=True,
              sub_struct=None
          )
      }
  )
  ```

  Call it with `include_sub_structs_details=True` to get more details about the sub-structs, in the `sub_struct` field (recursively)
  ```python
  StructLayoutInfo(
      name='Rectangle',
      struct_class=<class '__main__.Rectangle'>
      endianness=<Endianness.NATIVE: '='>,
      byte_order=<Endianness.LITTLE: '<'>,
      struct_format='HHHH'
      nb_bytes=8
      offset=0
      fields={
          'corners': FieldLayoutInfo(
              name='corners'
              offset=0
              nb_bytes=8
              struct_format='HHHH'
              nb_items=2
              dimensions=(2,)
              python_type=<class '__main__.Point'>
              python_full_type=list[__main__.Point],
              is_sub_struct=True,
              sub_struct=StructLayoutInfo(
                  name='Point',
                  struct_class=<class '__main__.Point'>,
                  endianness=<Endianness.NATIVE: '='>,
                  byte_order=<Endianness.LITTLE: '<'>,
                  struct_format='HH'
                  nb_bytes=4
                  offset=0
                  fields={
                      'x': FieldLayoutInfo(
                          name='x'
                          offset=0
                          nb_bytes=2
                          struct_format='H',
                          nb_items=1,
                          dimensions=None,
                          python_type=<class 'int'>,
                          python_full_type=<class 'int'>,
                          is_sub_struct=False,
                          sub_struct=None
                      ),
                      'y': FieldLayoutInfo(
                          name='y',
                          offset=2,
                          nb_bytes=2,
                          struct_format='H',
                          nb_items=1,
                          dimensions=None,
                          python_type=<class 'int'>,
                          python_full_type=<class 'int'>,
                          is_sub_struct=False,
                          sub_struct=None
                      )
                  }
              )
          )
      }
  )
  ```



  You can get a `rich` (https://rich.readthedocs.io/en/latest) table representation of a structure with the `print_rich_table` function from `databytes.utils`:

  Taking the previous example strucs:

  ```python
  from databytes.utils import print_rich_table

  print_rich_table(Rectangle)
  ```

  Will give you:
  ```bash
                    Layout of Rectangle (8 bytes)
  ┏━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━┓
  ┃ Name    ┃ Offset ┃ Nb bytes ┃ Format ┃ Dimensions ┃ Python Type ┃
  ┡━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━┩
  │ corners │      0 │        8 │ HHHH   │       (2,) │ list[Point] │
  └─────────┴────────┴──────────┴────────┴────────────┴─────────────┘
  ```

  calling it with `include_sub_structs_details=True` will give you more details about the sub-structs:
  ```bash
                     Layout of Rectangle (8 bytes)
  ┏━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━┓
  ┃ Name    ┃ Offset ┃ Nb bytes ┃ Format ┃ Dimensions ┃ Python Type ┃
  ┡━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━┩
  │ corners │      0 │        8 │ HHHH   │       (2,) │ list[Point] │
  └─────────┴────────┴──────────┴────────┴────────────┴─────────────┘
                     Layout of Point (4 bytes)
  ┏━━━━━━┳━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━┓
  ┃ Name ┃ Offset ┃ Nb bytes ┃ Format ┃ Dimensions ┃ Python Type ┃
  ┡━━━━━━╇━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━┩
  │ x    │      0 │        2 │ H      │       None │ int         │
  │ y    │      2 │        2 │ H      │       None │ int         │
  └──────┴────────┴──────────┴────────┴────────────┴─────────────┘
  ```

  Instead of `print_riche_table` you can use `get_rich_table_string` so you can print it the way you want. Or `get_rich_table` to integrate the result in another rich component.

  You can install the `rich` library independantly or by installing databytes with the `[extra]` dependency (`pip install databytes[extra]`).




  We have our own `mypy` plugin so that `mypy` understands that `field: t.uint16` will resolve to an `int`, or `field: t.uint16[2]` will resolve to a `list[int]`.

  It will also ensure that the dimensions (in `[]`) are literal positive integers.

  To use the plugin, in your mypy configuration add `databytes.mypy_plugin` to your list of plugins.




  To set up the development environment, first create a virtual environment using the method of your choice, activate it and, in it:

  ```bash

  make dev


  make format  # or `make pretty`


  make lint


  make tests


  make checks
  ```



  MIT License - See the LICENSE file for details.



  Stephane "Twidi" Angel (s.angel@twidi.com)



  - Source: https://github.com/twidi/databytes
  - Author's website: https://twidi.com

rpm_license:
  Copyright (c) 2024-present Stéphane "Twidi" Angel.  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


pkgId: 973b57c5cba5c7da5af2f6a6b9875aab38db405aae722c0c319892c1b425231c
name: python-datacatalog-tag-manager
arch: src
version: 2.2.0
epoch: 0
release: 1
summary: A package to manage Google Cloud Data Catalog tags, loading metadata from external sources
url: https://github.com/ricardolsmendes/datacatalog-tag-manager
rpm_license: MIT
rpm_group: Unspecified
rpm_buildhost: localhost
location_href: Packages/python-datacatalog-tag-manager-2.2.0-1.src.rpm
checksum_type: sha256
description:
  Using [virtualenv][3] is optional, but strongly recommended unless you use [Docker](#12-docker).


  This is recommended so all related stuff will reside at same place, making it easier to follow
  below instructions.
  ````bash
  mkdir ./datacatalog-tag-manager
  cd ./datacatalog-tag-manager
  ````
  _All paths starting with `./` in the next steps are relative to the `datacatalog-tag-manager`
  folder._

  ```bash
  pip install --upgrade virtualenv
  python3 -m virtualenv --python python3 env
  source ./env/bin/activate
  ```

  ```bash
  pip install --upgrade datacatalog-tag-manager
  ```

  Docker may be used as an alternative to run `datacatalog-tag-manager`. In this case, please
  disregard the [above](#11-python--virtualenv) _virtualenv_ setup instructions.

  ```bash
  git clone https://github.com/ricardolsmendes/datacatalog-tag-manager
  cd ./datacatalog-tag-manager
  ```


  - BigQuery Metadata Viewer
  - Data Catalog TagTemplate User
  - A custom role with `bigquery.datasets.updateTag` and `bigquery.tables.updateTag` permissions

  - `./credentials/datacatalog-tag-manager.json`

  _This step may be skipped if you're using [Docker](#12-docker)._
  ```bash
  export GOOGLE_APPLICATION_CREDENTIALS=./credentials/datacatalog-tag-manager.json
  ```



  - *SCHEMA*
  The metadata schema to create or update Tags is presented below. Use as many lines as needed to
  describe all the Tags and Fields you need.
  | Column                            | Description                                                                                                                 | Mandatory |
  | --------------------------------- | --------------------------------------------------------------------------------------------------------------------------- | :-------: |
  | **linked_resource OR entry_name** | Full name of the BigQuery or PubSub asset the Entry refers to, or an Entry name if you are working with [Custom Entries][4] |    yes    |
  | **template_name**                 | Resource name of the Tag Template for the Tag                                                                               |    yes    |
  | **column**                        | Attach Tags to a column belonging to the Entry schema                                                                       |    no     |
  | **field_id**                      | Id of the Tag field                                                                                                         |    yes    |
  | **field_value**                   | Value of the Tag field                                                                                                      |    yes    |
  - *SAMPLE INPUT*
  1. [sample-input/upsert-tags][5] for reference;
  1. [Data Catalog Sample Tags][7] (Google Sheets) might help to create/export a CSV file.
  - *COMMANDS*
  **Python + virtualenv**
  ```bash
  datacatalog-tags upsert --csv-file <CSV-FILE-PATH>
  ```
  **Docker**
  ```bash
  docker build --rm --tag datacatalog-tag-manager .
  docker run --rm --tty \
    --volume <CREDENTIALS-FILE-FOLDER>:/credentials --volume <CSV-FILE-FOLDER>:/data \
    datacatalog-tag-manager upsert --csv-file /data/<CSV-FILE-PATH>
  ```


  - *SCHEMA*
  The metadata schema to delete Tags is presented below. Use as many lines as needed to delete all
  the Tags you want.
  | Column                            | Description                                                                                                                 | Mandatory |
  | --------------------------------- | --------------------------------------------------------------------------------------------------------------------------- | :-------: |
  | **linked_resource OR entry_name** | Full name of the BigQuery or PubSub asset the Entry refers to, or an Entry name if you are working with [Custom Entries][4] |    yes    |
  | **template_name**                 | Resource name of the Tag Template of the Tag                                                                                |    yes    |
  | **column**                        | Delete Tags from a column belonging to the Entry schema                                                                     |    no     |
  - *SAMPLE INPUT*
  1. [sample-input/delete-tags][6] for reference;
  1. [Data Catalog Sample Tags][7] (Google Sheets) might help to create/export a CSV file.
  - *COMMANDS*
  **Python + virtualenv**
  ```bash
  datacatalog-tags delete --csv-file <CSV-FILE-PATH>
  ```
  **Docker**
  ```bash
  docker build --rm --tag datacatalog-tag-manager .
  docker run --rm --tty \
    --volume <CREDENTIALS-FILE-FOLDER>:/credentials --volume <CSV-FILE-FOLDER>:/data \
    datacatalog-tag-manager delete --csv-file /data/<CSV-FILE-PATH>
  ```
  [1]: https://github.com/ricardolsmendes/datacatalog-tag-manager/workflows/Continuous%20Integration/badge.svg
  [2]: https://github.com/ricardolsmendes/datacatalog-tag-manager/workflows/Continuous%20Delivery/badge.svg
  [3]: https://virtualenv.pypa.io/en/latest/
  [4]: https://cloud.google.com/data-catalog/docs/how-to/custom-entries
  [5]: https://github.com/ricardolsmendes/datacatalog-tag-manager/tree/master/sample-input/upsert-tags
  [6]: https://github.com/ricardolsmendes/datacatalog-tag-manager/tree/master/sample-input/delete-tags
  [7]: https://docs.google.com/spreadsheets/d/1bqeAXjLHUq0bydRZj9YBhdlDtuu863nwirx8t4EP_CQ


pkgId: 15336d2da1eb7da8ea1fa8f6fbdc15a4b978d30139e79a5be0493c40727763e3
name: python-datacatalog-util
arch: src
version: 0.11.6
epoch: 0
release: 1
summary: A package to manage Google Cloud Data Catalog helper commands and scripts
url: https://github.com/mesmacosta/datacatalog-util
rpm_license: MIT license
rpm_group: Unspecified
rpm_buildhost: localhost
location_href: Packages/python-datacatalog-util-0.11.6-1.src.rpm
checksum_type: sha256
description:
  [![Open in Cloud Shell](http://gstatic.com/cloudssh/images/open-btn.svg)](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/mesmacosta/datacatalog-util&tutorial=tutorials/TUTORIAL.md)
  <!--
    ⚠️ DO NOT UPDATE THE TABLE OF CONTENTS MANUALLY ️️⚠️
    run `npx markdown-toc -i README.md`.
    Please stick to 80-character line wraps as much as you can.
  -->

  <!-- toc -->
  - [0. Executing in Cloud Shell from PyPi](#0-executing-in-cloud-shell-from-pypi)
  - [1. Environment setup for local build](#1-environment-setup-for-local-build)
    * [1.1. Python + virtualenv](#11-python--virtualenv)
      + [1.1.1. Install Python 3.6+](#111-install-python-36)
      + [1.1.2. Get the source code](#112-get-the-source-code)
      + [1.1.3. Create and activate an isolated Python environment](#113-create-and-activate-an-isolated-python-environment)
      + [1.1.4. Install the package](#114-install-the-package)
    * [1.2. Docker](#12-docker)
    * [1.3. Auth credentials](#13-auth-credentials)
      + [1.3.1. Create a service account and grant it below roles](#131-create-a-service-account-and-grant-it-below-roles)
      + [1.3.2. Download a JSON key and save it as](#132-download-a-json-key-and-save-it-as)
      + [1.3.3. Set the environment variables](#133-set-the-environment-variables)
  - [2. Load Tags from CSV file](#2-load-tags-from-csv-file)
    * [2.1. Create a CSV file representing the Tags to be created](#21-create-a-csv-file-representing-the-tags-to-be-created)
      + [2.1.1 Execute Tutorial in Cloud Shell](#211-execute-tutorial-in-cloud-shell)
    * [2.2. Run the datacatalog-util script - Create the Tags](#22-run-the-datacatalog-util-script---create-the-tags)
    * [2.3. Run the datacatalog-util script - Delete the Tags](#23-run-the-datacatalog-util-script---delete-the-tags)
  - [3. Export Tags to CSV file](#3-export-tags-to-csv-file)
    * [3.1. A list of CSV files, each representing one Template will be created.](#31-a-list-of-csv-files-each-representing-one-template-will-be-created)
      + [3.1.1 Execute Tutorial in Cloud Shell](#311-execute-tutorial-in-cloud-shell)
    * [3.2. Run tags export](#32-run-tags-export)
    * [3.3 Run tags export filtering Tag Templates](#33-run-tags-export-filtering-tag-templates)
  - [4. Load Templates from CSV file](#4-load-templates-from-csv-file)
    * [4.1. Create a CSV file representing the Templates to be created](#41-create-a-csv-file-representing-the-templates-to-be-created)
      + [4.1.1 Execute Tutorial in Cloud Shell](#411-execute-tutorial-in-cloud-shell)
    * [4.2. Run the datacatalog-util script - Create the Tag Templates](#42-run-the-datacatalog-util-script---create-the-tag-templates)
    * [4.3. Run the datacatalog-util script - Delete the Tag Templates](#43-run-the-datacatalog-util-script---delete-the-tag-templates)
  - [5. Export Templates to CSV file](#5-export-templates-to-csv-file)
    * [5.1. A CSV file representing the Templates will be created](#51-a-csv-file-representing-the-templates-will-be-created)
      + [5.1.1 Execute Tutorial in Cloud Shell](#511-execute-tutorial-in-cloud-shell)
    * [5.2. Run the datacatalog-util script](#52-run-the-datacatalog-util-script)
  - [6. Filesets Commands](#6-filesets-commands)
    * [6.1. Create a CSV file representing the Entry Groups and Entries to be created](#61-create-a-csv-file-representing-the-entry-groups-and-entries-to-be-created)
      + [6.1.1 Execute Tutorial in Cloud Shell](#611-execute-tutorial-in-cloud-shell)
    * [6.2. Create the Filesets Entry Groups and Entries](#62-create-the-filesets-entry-groups-and-entries)
      + [6.2.1 Create the Filesets Entry Groups and Entries - with DataFlow SQL types validation](#621-create-the-filesets-entry-groups-and-entries---with-dataflow-sql-types-validation)
    * [6.3. Enrich GCS Filesets with Tags](#63-enrich-gcs-filesets-with-tags)
      + [6.3.1 Enrich all fileset entries using Tag Template from a different Project (Good way to reuse the same Template)](#631-enrich-all-fileset-entries-using-tag-template-from-a-different-project-good-way-to-reuse-the-same-template)
      + [6.3.2 Execute Fileset Enricher Tutorial in Cloud Shell](#632-execute-fileset-enricher-tutorial-in-cloud-shell)
    * [6.4. clean up template and tags](#64-clean-up-template-and-tags)
    * [6.5. Delete the Filesets Entry Groups and Entries](#65-delete-the-filesets-entry-groups-and-entries)
  - [7. Export Filesets to CSV file](#7-export-filesets-to-csv-file)
    * [7.1. A CSV file representing the Filesets will be created](#71-a-csv-file-representing-the-filesets-will-be-created)
      + [7.1.1 Execute Tutorial in Cloud Shell](#711-execute-tutorial-in-cloud-shell)
    * [7.2. Run the datacatalog-util script](#72-run-the-datacatalog-util-script)
  - [8. DataCatalog Object Storage commands](#8-datacatalog-object-storage-commands)
    * [8.1 Execute Tutorial in Cloud Shell](#81-execute-tutorial-in-cloud-shell)
    * [8.2. Create DataCatalog entries based on object storage files](#82-create-datacatalog-entries-based-on-object-storage-files)
    * [8.3. Delete object storage entries on entry group](#83-delete-object-storage-entries-on-entry-group)
  - [9. Data Catalog Templates Examples](#9-data-catalog-templates-examples)


pkgId: 7a8d109179e10070c59a3bbdf42366fb04fdfaf11cbea921daf6558ca51b0277
name: python-datachecks
arch: src
version: 0.3.1
epoch: 0
release: 1
summary: Open Source Data Quality Monitoring
url: https://github.com/waterdipai/datachecks
rpm_license: Apache-2.0
rpm_group: Unspecified
rpm_buildhost: localhost
location_href: Packages/python-datachecks-0.3.1-1.src.rpm
checksum_type: sha256
description:
  <p align="center">
      <img alt="Logo" src="https://raw.githubusercontent.com/waterdipai/datachecks/main/docs/assets/datachecks_banner_logo.svg" width="1512">
  </p>
  <p align="center"><b>Open Source Data Quality Monitoring.</b></p>

  <p align="center">
      <img align="center" alt="License" src="https://img.shields.io/badge/License-Apache%202.0-blue.svg"/>
      <img align="center" src="https://img.shields.io/pypi/pyversions/datachecks"/>
      <img align="center" alt="Versions" src="https://img.shields.io/pypi/v/datachecks"/>
      <img align="center" alt="coverage" src="https://static.pepy.tech/personalized-badge/datachecks?period=total&units=international_system&left_color=black&right_color=green&left_text=Downloads"/>
      <img align="center" alt="coverage" src="https://codecov.io/gh/waterdipai/datachecks/branch/main/graph/badge.svg?token=cn6lkDRXpl">
      <img align="center" alt="Status" src="https://github.com/waterdipai/datachecks/actions/workflows/ci.yml/badge.svg?branch=main"/>
  </p>

  <div align="center">
  ⭐️ If you like it, star the repo <a href="https://github.com/waterdipai/waterdip/stargazers"></a> ⭐

  <h3>|
  <a href="https://docs.datachecks.io/">Documentations</a>
  |
  <a href="https://join.slack.com/t/datachecks/shared_invite/zt-1zqsigy4i-s5aadIh2mjhdpVWU0PstPg">Slack Community</a>
  |
  </h3>
  </div>



  APM (Application Performance Monitoring) tools are used to monitor the performance of applications. APM tools are mandatory part of dev stack. Without AMP tools, it is very difficult to monitor the performance of applications.

  <p align="center">
      <img alt="why_data_observability" src="https://raw.githubusercontent.com/waterdipai/datachecks/main/docs/assets/datachecks_why_data_observability.svg" width="800">
  </p>

  But for Data products regular APM tools are not enough. We need a new kind of tools that can monitor the performance of Data applications.
  Data monitoring tools are used to monitor the data quality of databases and data pipelines. It identifies potential issues, including in the databases and data pipelines. It helps to identify the root cause of the data quality issues and helps to improve the data quality.



  Datachecks is an open-source data monitoring tool that helps to monitor the data quality of databases and data pipelines.
  It identifies potential issues, including in the databases and data pipelines. It helps to identify the root cause of the data quality issues and helps to improve the data quality.

  Datachecks can generate several reliability, uniqueness, completeness metrics from several data sources



  You can generate with just one command. It generates a beautiful data quality report with all the metrics.
  This html report can be shared with the team.

  <p align="center">
      <img alt="why_data_observability" src="docs/assets/datachecks_dashboard.png" width="800">
  </p>



  Data quality report can be generated in the terminal. It is very useful for debugging. All it takes is one command.

  <p align="center">
      <img alt="why_data_observability" src="docs/assets/datachecks_cli_output.png" width="800">
  </p>



  Install `datachecks` with the command that is specific to the database.



  To install all datachecks dependencies, use the below command.

  ```shell
  pip install datachecks -U
  ```



  With a simple config file, you can generate data quality reports for your data sources. Below is the sample config example.
  For more details, please visit the [config guide](https://docs.datachecks.io/configuration/metric_configuration/)

  <p align="center">
      <img alt="why_data_observability" src="docs/assets/datachecks_config.png" width="800">
  </p>



  **Generate Report in Terminal**

  ```shell
  datachecks inspect -C config.yaml
  ```

  **Generate HTML Report**

  ```shell
  datachecks inspect -C config.yaml  --html-report
  ```

  Please visit the [Quick Start Guide](https://docs.datachecks.io/getting_started/)



  Datachecks supports sql and search data sources. Below are the list of supported data sources.

  | Data Source                                                             | Type                   | Supported  |
  | ----------------------------------------------------------------------- | ---------------------- | ---------- |
  | [Postgres](https://docs.datachecks.io/integrations/postgres/)           | Transactional Database | :thumbsup: |
  | [MySql](https://docs.datachecks.io/integrations/mysql/)                 | Transactional Database | :thumbsup: |
  | [MS SQL Server](https://docs.datachecks.io/integrations/mssql/)         | Transactional Database | :thumbsup: |
  | [OpenSearch](https://docs.datachecks.io/integrations/opensearch/)       | Search Engine          | :thumbsup: |
  | [Elasticsearch](https://docs.datachecks.io/integrations/elasticsearch/) | Search Engine          | :thumbsup: |
  | [GCP BigQuery](https://docs.datachecks.io/integrations/bigquery/)       | Data Warehouse         | :thumbsup: |
  | [DataBricks](https://docs.datachecks.io/integrations/databricks/)       | Data Warehouse         | :thumbsup: |
  | [Snowflake](https://docs.datachecks.io/integrations/snowflake/)         | Data Warehouse         | :thumbsup: |
  | AWS RedShift                                                            | Data Warehouse         | :x:        |



  | Metric                                                                                       | Description                                                                                                      |
  | -------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- |
  | **[Reliability Metrics](https://docs.datachecks.io/metrics/reliability/)**                   | Reliability metrics detect whether tables/indices/collections are updating with timely data                      |
  | **[Numeric Distribution Metrics](https://docs.datachecks.io/metrics/numeric_distribution/)** | Numeric Distribution metrics detect changes in the numeric distributions i.e. of values, variance, skew and more |
  | **[Uniqueness Metrics](https://docs.datachecks.io/metrics/uniqueness/)**                     | Uniqueness metrics detect when data constraints are breached like duplicates, number of distinct values etc      |
  | **[Completeness Metrics](https://docs.datachecks.io/metrics/completeness/)**                 | Completeness metrics detect when there are missing values in datasets i.e. Null, empty value                     |
  | **Validity Metrics**                                                                         | Validity metrics detect whether data is formatted correctly and represents a valid value                         |



  <p align="center">
      <img alt="datacheck_architecture" src="https://raw.githubusercontent.com/waterdipai/datachecks/main/docs/assets/data_check_architecture.svg" width="800">
  </p>



  <p align="middle">
    <img alt="" src="https://raw.githubusercontent.com/waterdipai/datachecks/main/docs/assets/datachecks_does_not_do.svg" width="800"/>
  </p>



  For additional information and help, you can use one of these channels:

  - [Slack](https://join.slack.com/t/datachecks/shared_invite/zt-1zqsigy4i-s5aadIh2mjhdpVWU0PstPg) \(Live chat with the team, support, discussions, etc.\)
  - [GitHub issues](https://github.com/waterdipai/datachecks/issues) \(Bug reports, feature requests)



  :raised_hands: We greatly appreciate contributions - be it a bug fix, new feature, or documentation!

  Check out the [contributions guide](https://github.com/waterdipai/datachecks/blob/main/CONTRIBUTING.md) and [open issues](https://github.com/waterdipai/datachecks/issues).

  **Datachecks contributors: :blue_heart:**

  <a href="https://github.com/subhankarb"><img src="https://avatars.githubusercontent.com/u/2178361?v=4" width="50" height="50" alt=""/></a>
  <a href="https://github.com/niyasrad"><img src="https://avatars.githubusercontent.com/u/84234554?v=4" width="50" height="50" alt=""/></a>
  <a href="https://github.com/WeryZebra-Yue"><img src="https://avatars.githubusercontent.com/u/75676675?v=4" width="50" height="50" alt=""/></a>
  <a href="https://github.com/gaurav-wdi"><img src="https://avatars.githubusercontent.com/u/82873511?v=4" width="50" height="50" alt=""/></a>
  <a href="https://github.com/PULAK0717"><img src="https://avatars.githubusercontent.com/u/101057457?v=4" width="50" height="50" alt=""/></a>
  <a href="https://github.com/fabriciodadosbr"><img src="https://avatars.githubusercontent.com/u/96063978?v=4" width="50" height="50" alt=""/></a>



  [Usage Analytics & Data Privacy](https://github.com/waterdipai/datachecks/blob/main/docs/support/usage_analytics.md)



  This project is licensed under the terms of the [APACHE 2 License](https://github.com/waterdipai/datachecks/blob/main/LICENSE).


pkgId: 9bb16fbb52ee3b98ba48ab4a25a83695a3d0132e1a781f61f918f8119e15eaac
name: python-dataclass-bakery
arch: src
version: 0.0.8
epoch: 0
release: 1
url: https://github.com/miguelFLG13/dataclass-bakery
rpm_license: UNKNOWN
rpm_group: Unspecified
rpm_buildhost: localhost
location_href: Packages/python-dataclass-bakery-0.0.8-1.src.rpm
checksum_type: sha256
summary:
  Dataclass Bakery offers you a smart way to create objects based on dataclasses for testing in Python

description:
  Dataclass Bakery offers you a smart way to create objects based on dataclasses for testing in Python.
  Inspired in model bakery module for Django.
  Install
  ~~~~~~~
  ``pip install dataclass_bakery``
  Usage and Info
  ~~~~~~~~~~~~~~
  Basic usage
  ^^^^^^^^^^^
      from dataclasses import dataclass
      from dataclass_bakery import baker
      @dataclass
      class Customer:
          id: int
          name: str
          spent_money: float
      baker.make(Customer)
      baker.make(Customer, _quantity=3)
      """
      Customer(id=25, name='vzWoIfgoZM', spent_money=16.36)
      [Customer(id=27, name='OYvyWakmUX', spent_money=84.98), Customer(id=41, name='AiancdsmLg', spent_money=57.57), Customer(id=92, name='feTxLyuSus', spent_money=26.06)]
      """
  For more information: https://dataclass-bakery.readthedocs.io/
  Types available:
  ^^^^^^^^^^^^^^^^
  -  int
  -  str
  -  float
  -  bool
  -  complex
  -  date
  -  datetime
  -  range
  -  list
  -  tuple
  -  dict
  -  set
  -  List (from typing import List)
  -  Tuple (from typing import Tuple)
  -  Dict (from typing import Dict)
  -  Union (from typing import Union)
  -  Optional (from typing import Optional)
  -  Path (from pathlib import Path)
  -  Decimal (from decimal import Decimal)
  -  UUID (from uuid import UUID)


pkgId: c92348cc46ba841aa66b874458a30558ed0a5003b48d560b95b82fe66f344619
name: python-dataclass-binder
arch: src
version: 0.3.4
epoch: 0
release: 1
summary: Library to bind TOML data to Python dataclasses in a type-safe way.
url: https://github.com/ProtixIT/dataclass-binder
rpm_license: MIT
rpm_group: Unspecified
rpm_buildhost: localhost
location_href: Packages/python-dataclass-binder-0.3.4-1.src.rpm
checksum_type: sha256
description:
  Library to bind TOML data to Python dataclasses in a type-safe way.




  Currently it has the following properties that might set it apart from other data binding libraries:

  - requires Python 3.10+
  - relies only on dataclasses from the Python standard library
  - detailed error messages which mention location, expected data and actual data
  - strict parsing which considers unknown keys to be errors
  - support for durations (`timedelta`)
  - support for immutable (frozen) dataclasses
  - can bind data from files, I/O streams or pre-parsed dictionaries
  - can generate configuration templates from dataclass definitions

  This library was originally designed for parsing configuration files.
  As TOML's data model is very similar to JSON's, adding support for JSON in the future would be an option and would make the library useful for binding HTTP API requests.




  This library is fully type-checked, has unit tests which provide 100% branch coverage and is used in production, so it should be reliable.

  The API might still change in incompatible ways until the 1.0 release.
  In particular the following aspects are subject to change:

  - use of key suffixes for `timedelta`: this mechanism doesn't work for arrays
  - the handling of separators in keys: currently `-` in TOML is mapped to `_` in Python and `_` is forbidden in TOML; most applications seem to accept both `-` and `_` in TOML instead




  A typical TOML, JSON or YAML parser returns the parse results as a nested dictionary.
  You might wonder why you would want to use a data binding library rather than just getting the values directly from that dictionary.

  Let's take the following example code for a service that connects to a database using a connection URL configured in a TOML file:

  ```py
  import tomllib  # or 'tomli' on Python <3.11


  def read_config() -> dict:
      with open("config.toml", "rb") as f:
          config = tomllib.load(f)
      return config

  def handle_request(config: dict) -> None:
      url = config["database-url"]
      print("connect to database:", url)

  config = read_config()
  ...
  handle_request(config)
  ```

  If the configuration is missing a `database-url` key or its value is not a string, this service would start up without complaints and then fail when the first requests comes in.
  It would be better to instead check the configuration on startup, so let's add code for that:

  ```py
  def read_config():
      with open("config.toml", "rb") as f:
          config = tomllib.load(f)

      url = config["database-url"]
      if not isinstance(url, str):
          raise TypeError(
              f"Value for 'database-url' has type '{type(url).__name__}', expected 'str'"
          )

      return config
  ```

  Imagine you have 20 different configurable options: you'd need this code 20 times.

  Now let's assume that you use a type checker like `mypy`.
  Inside `read_config()`, the type checker will know that `url` is a `str`, but if you fetch the same value elsewhere in the code, that information is lost:

  ```py
  def handle_request(config: dict) -> None:
      url = config["database-url"]
      reveal_type(url)
      print("connect to database:", url)
  ```

  When you run `mypy` on this code, it will output 'Revealed type is "Any"'.
  Falling back to `Any` means type checking will not be able to find type mismatches and autocomplete in an IDE will not work well either.

  Declaring the desired type in a dataclass solves both these issues:
  - the type can be verified at runtime before instantiating the dataclass
  - tooling knows the type when you read the value from the dataclass

  Having the dataclass as a central and formal place for defining the configuration format is also an advantage.
  For example, it enables automatic generation of a documented configuration file template.




  The `dataclass_binder` module contains the `Binder` class which makes it easy to bind TOML data, such as a configuration file, to Python [dataclasses](https://docs.python.org/3/library/dataclasses.html).

  The binding is a two-step process:
  - instantiate the `Binder` class by passing your top-level dataclass as an argument
  - call the `parse_toml()` method, providing the path of the configuration file as its argument

  Put together, the code looks like this:

  ```py
  import logging
  import sys
  from pathlib import Path

  from dataclass_binder import Binder


  logger = logging.getLogger(__name__)

  if __name__ == "__main__":
      config_file = Path("config.toml")
      try:
          config = Binder(Config).parse_toml(config_file)
      except Exception as ex:
          logger.critical("Error reading configuration file '%s': %s", config_file, ex)
          sys.exit(1)
  ```



  If you don't want to bind the contents of a full file, there is also the option to bind a pre-parsed dictionary instead.
  For this, you can use the `bind()` method on the `Binder` object.

  For example, the following service is configured by one table within a larger TOML configuration file:

  ```py
  import tomllib  # or 'tomli' on Python <3.11
  from dataclass_binder import Binder


  with open("config.toml", "rb") as f:
      config = tomllib.load(f)
  service_config = Binder(ServiceConfig).bind(config["service"])
  ```

  To keep these examples short, from now on `import` statements will only be included the first time a particular imported name is used.



  Dataclass fields correspond to TOML keys. In the dataclass, underscores are used as word separators, while dashes are used in the TOML file. Let's configure a service that listens on a TCP port for requests and stores its data in a database, using the following TOML fragment:

  ```toml
  database-url = 'postgresql://user:password@host/db'
  port = 8080
  ```

  This configuration can be bound to the following dataclass:

  ```py
  from dataclasses import dataclass

  @dataclass
  class Config:
      database_url: str
      port: int
      verbose: bool
  ```

  The `float` type can be used to bind floating point numbers.
  Support for `Decimal` is not there at the moment but would be relatively easy to add, as `tomllib`/`tomli` has an option for that.



  Fields can be made optional by assigning a default value. Using `None` as a default value is allowed too:

  ```py
  @dataclass
  class Config:
      verbose: bool = False
      webhook_url: str | None = None
  ```

  If you want to mix fields with and without defaults in any order, mark the fields as keyword-only:

  ```py
  @dataclass(kw_only=True)
  class Config:
      database_url: str
      verbose: bool = False
      port: int
  ```



  While you can of course store file system paths as strings, [pathlib](https://docs.python.org/3/library/pathlib.html) offers a nicer API for them.
  To take advantage of this, annotate the field as `Path`:

  ```py
  from pathlib import Path

  @dataclass
  class Config:
      log_dir: Path

      def create_log_dir(self) -> None:
          self.log_dir.mkdir(parents=True)
  ```



  TOML handles dates and timestamps as first-class values.
  Date, time and date+time TOML values are bound to `datetime.date`, `datetime.time` and `datetime.datetime` Python objects respectively.

  There is also support for time intervals using `datetime.timedelta`:

  ```py
  from datetime import timedelta

  @dataclass
  class Config:
      retry_after: timedelta
      delete_after: timedelta
  ```

  Intervals shorter than a day can be specified using a TOML time value.
  Longer intervals are supported by adding an `-hours`, `-days`, or `-weeks` suffix.
  Other supported suffixes are `-minutes`, `-seconds`, `-milliseconds` and `-microseconds`, but these are there for completeness sake and less likely to be useful.
  Here is an example TOML fragment corresponding to the dataclass above:

  ```toml
  retry-after = 00:02:30
  delete-after-days = 30
  ```



  Lists and dictionaries can be used to bind TOML arrays and tables.
  If you want to make a `list` or `dict` optional, you need to provide a default value via the `default_factory` mechanism as usual, see the [dataclasses documentation](https://docs.python.org/3/library/dataclasses.html#mutable-default-values) for details.

  ```py
  from dataclasses import dataclass, field

  @dataclass
  class Config:
      tags: list[str] = field(default_factory=list)
      limits: dict[str, int]
  ```

  The dataclass above can be used to bind the following TOML fragment:

  ```toml
  tags = ["production", "development"]
  limits = {ram-gb = 1, disk-gb = 100}
  ```

  An alternative to `default_factory` is to use a homogeneous (single element type) tuple:

  ```py
  @dataclass
  class Config:
      tags: tuple[str, ...] = ()
      limits: dict[str, int]
  ```

  Heterogeneous tuples are supported too: for example `tuple[str, bool]` binds a TOML array that must always have a string as its first element and a Boolean as its second and last element.
  It is generally clearer though to define a separate dataclass when you need more than one value to configure something:

  ```py
  @dataclass
  class Webhook:
      url: str
      token: str

  @dataclass
  class Config:
      webhooks: tuple[Webhook, ...] = ()
  ```

  The extra keys (`url` and `token` in this example) provide the clarity:

  ```toml
  webhooks = [
      {url = "https://host1/notify", token = "12345"},
      {url = "https://host2/hook", token = "frperg"}
  ]
  ```

  TOML's array-of-tables syntax can make this configuration a bit easier on the eyes:

  ```toml
  [[webhooks]]
  url = "https://host1/notify"
  token = "12345"

  [[webhooks]]
  url = "https://host2/hook"
  token = "frperg"
  ```

  Always define additional dataclasses at the module level in your Python code: if the class is for example defined inside a function, the `Binder` constructor will not be able to find it.



  Sometimes the full structure of the data you want to bind is either too complex or too much in flux to be worth fully annotating.
  In such a situation, you can use `typing.Any` as the annotation to simply capture the output of Python's TOML parser without type-checking it.

  In the following example, a service uses the Python standard library logging implementation, configured using the [configuration dictionary schema](https://docs.python.org/3/library/logging.config.html#logging-config-dictschema):

  ```py
  import logging.config
  from dataclasses import dataclass
  from typing import Any

  from dataclass_binder import Binder


  @dataclass
  class Config:
      database_url: str
      logging: Any


  def run(url: str) -> None:
      logging.info("Service starting")


  if __name__ == "__main__":
      config = Binder[Config].parse_toml("service.toml")
      logging.config.dictConfig(config.logging)
      run(config.database_url)
  ```

  The `service.toml` configuration file for this service could look like this:

  ```toml
  database-url = 'postgresql://user:password@host/db'

  [logging]
  version = 1

  [logging.root]
  level = 'INFO'
  handlers = ['file']

  [logging.handlers.file]
  class = 'logging.handlers.RotatingFileHandler'
  filename = 'service.log'
  formatter = 'simple'

  [logging.formatters.simple]
  format = 's s s s'
  ```



  To select plugins to activate, you can bind Python classes or modules using `type[BaseClass]` and `types.ModuleType` annotations respectively:

  ```py
  from dataclasses import dataclass, field
  from types import ModuleType

  from supertool.plugins import PostProcessor


  @dataclass
  class PluginConfig:
      postprocessors = tuple[type[PostProcessor], ...] = ()
      modules: dict[str, ModuleType] = field(default_factory=dict)
  ```

  In the TOML, you specify Python classes or modules using their fully qualified names:

  ```toml
  postprocessors = ["supertool_addons.reporters.JSONReport"]
  modules = {lint = "supertool_addons.linter"}
  ```

  There is no mechanism yet to add configuration to be used by the plugins.



  If you prefer immutable configuration objects, you can achieve that using the `frozen` argument of the `dataclass` decorator and using abstract collection types in the annotations. For example, the following dataclass will be instantiated with a `tuple` object for `tags` and an immutable dictionary view for `limits`:

  ```py
  from collections.abc import Mapping, Sequence


  @dataclass(frozen=True)
  class Config:
      tags: Sequence[str] = ()
      limits: Mapping[str, int]
  ```



  `Binder` can be instantiated from a dataclass object rather than the dataclass itself.
  The dataclass object will provide new default values when binding data to it.
  This can be used to implement a layered configuration parsing mechanism, where there is a default configuration that can be customized using a system-wide configuration file and/or a per-user configuration file:

  ```py
  config = Config()
  if system_config_path.exists():
      config = Binder(config).parse_toml(system_config_path)
  if user_config_path.exists():
      config = Binder(config).parse_toml(user_config_path)
  ```

  Later layers can override individual fields in nested dataclasses, allowing fine-grained configuration merging, but collections are replaced whole instead of merged.



  To provide users with a starting point for configuring your application/service, you can automatically generate a configuration template from the information in the dataclass.

  For example, when the following dataclass defines your configuration:

  ```py
  @dataclass
  class Config:
      database_url: str
      """The URL of the database to connect to."""

      port: int = 12345
      """TCP port on which to accept connections."""
  ```

  You can generate a template configuration file using:

  ```py
  from dataclass_binder import Binder


  for line in Binder(Config).format_toml_template():
      print(line)
  ```

  Which will print:

  ```toml


  database-url = '???'




  ```

  It is also possible to provide placeholder values by passing a dataclass instance rather than the dataclass itself to `format_toml_template()`:

  ```py
  TEMPLATE = Config(
      database_url="postgresql://<username>:<password>@<hostname>/<database name>",
      port=8080,
  )

  for line in Binder(TEMPLATE).format_toml_template():
      print(line)
  ```

  Which will print:

  ```toml


  database-url = 'postgresql://<username>:<password>@<hostname>/<database name>'




  port = 8080
  ```



  If you want to generate a fully populated configuration, you can use the `format_toml()` method.
  Compared to the template formatting, this leaves out optional parts for which no data has been provided.

  For example, when the following dataclass defines your configuration:

  ```py
  @dataclass
  class Config:
      path: str
      """Path of input file."""

      verbose: bool = False
      """Be extra verbose in logging."""

      options: dict[str, Any] = field(default_factory=dict)
      """Various named options that are passed on to tool XYZ."""
  ```

  This code generates a populated configuration file:

  ```py
  config = Config(path="./data")

  with open("config.toml", "w") as out:
      for line in Binder(config).format_toml():
          print(line, file=out)
  ```

  With the contents of `config.toml` containing only the `path` field:

  ```toml

  path = './data'
  ```



  Finally, a troubleshooting tip: instead of the full `Binder(Config).parse_toml()`, first try to execute only `Binder(Config)`.
  If that fails, the problem is in the dataclass definitions.
  If that succeeds, but the `parse_toml()` call fails, the problem is that the TOML file does not match the format defined in the dataclasses.




  [Poetry](https://python-poetry.org/) is used to set up a virtual environment with all the dependencies and development tools that you need:

      $ cd dataclass-binder
      $ poetry install

  You can activate a shell which contains the development tools in its search path:

      $ poetry shell

  We recommend setting up pre-commit hooks for Git in the `dataclass-binder` work area.
  These hooks automatically run a few simple checks and cleanups when you create a new commit.
  After you first set up your virtual environment with Poetry, run this command to install the pre-commit hooks:

      $ pre-commit install




  - Verify that CI passes on the branch that you want to release (typically `main`)
  - Create a release on the GitHub web interface; name the tag `v<major>.<minor>.<patchlevel>`
  - After publishing the release on GitHub, the package will be built and published on PyPI automatically via Actions






  Prior to version 0.2.0, the `Binder` class was specialized using a type argument (`Binder[Config]`) rather than instantiation (`Binder(config)`). The old syntax is still supported for now, but the backwards compatibility might be removed in a minor release prior to 1.0 if it becomes a maintenance burden, so please update your code.



  In version 0.3.0, the function `format_template()` has been replaced by the method `Binder.format_toml_template()`. The old function is still available for now.





  - First open source release; thanks to my employer [Protix](https://protix.eu/) for making this possible



  - Relax `Binder.bind()` argument type to `Mapping` ([#3](https://github.com/ProtixIT/dataclass-binder/issues/3))



  - Fix `get()` and `[]` on object bound to read-only mapping ([#6](https://github.com/ProtixIT/dataclass-binder/issues/6))



  - Ignore dataclass fields with `init=False` ([#2](https://github.com/ProtixIT/dataclass-binder/issues/2))



  - Instantiate `Binder` instead of specializing it ([#14](https://github.com/ProtixIT/dataclass-binder/pull/14))
  - Support `typing.Any` as a field annotation ([#10](https://github.com/ProtixIT/dataclass-binder/issues/10))
  - Fix crash in `format_template()` on optional fields with non-string annotations ([#16](https://github.com/ProtixIT/dataclass-binder/pull/16))



  - Replace `format_template()` function by `Binder.format_toml_template()` method ([#23](https://github.com/ProtixIT/dataclass-binder/pull/23))
  - Format nested dataclasses as TOML tables ([#25](https://github.com/ProtixIT/dataclass-binder/pull/25))
  - Format untyped mappings and sequences as TOML tables ([#27](https://github.com/ProtixIT/dataclass-binder/pull/27))
  - Fix formatting of `init=False` field in nested dataclasses ([#22](https://github.com/ProtixIT/dataclass-binder/pull/22))
  - Fix annotation evaluation on inherited dataclasses ([#21](https://github.com/ProtixIT/dataclass-binder/pull/21))



  - Generate template in depth-first order ([#28](https://github.com/ProtixIT/dataclass-binder/pull/28))
  - Fix binder creation and formatting for recursive dataclasses ([#28](https://github.com/ProtixIT/dataclass-binder/pull/28))



  - Document fields with a `default_factory` as optional in template ([#35](https://github.com/ProtixIT/dataclass-binder/pull/35))
  - Omit values from template that are formatted equally to the default ([#36](https://github.com/ProtixIT/dataclass-binder/pull/36))
  - Require fields with `None` in their annotation to have `None` as their default ([#37](https://github.com/ProtixIT/dataclass-binder/pull/37))



  - Add `Binder.format_toml()` method to generate more compact TOML that excludes unused optional parts ([#38](https://github.com/ProtixIT/dataclass-binder/pull/38))



  - Support `pathlib.Path` as a field annotation ([#40](https://github.com/ProtixIT/dataclass-binder/issues/40))


pkgId: cd51ddef758c7c41f05a9da3f1aac13ca8724a9409a4b8b25e92d030c3ba58e5
name: python-dataclass-builder
arch: src
version: 1.2.0
epoch: 0
release: 1
summary: Create instances of dataclasses with the builder pattern.
url: https://github.com/mrshannon/dataclass-builder
rpm_license: MIT
rpm_group: Unspecified
rpm_buildhost: localhost
location_href: Packages/python-dataclass-builder-1.2.0-1.src.rpm
checksum_type: sha256
description:
  |build-status|
  |doc-status|
  |coverage-status|
  |code-style|
  |version|
  |supported-versions|
  |status|
  |license|
  Create instances of Python dataclasses with the builder pattern.


pkgId: 8c5531bfc1c49a1be4fd704e81663144e04147b5f6c137494b939f695e4e11c0
name: python-dataclass-codec
arch: src
version: 0.5.10
epoch: 0
release: 1
summary: please add a summary manually as the author left a blank one
url: https://pypi.org/project/dataclass-codec/
rpm_license: UNKNOWN
rpm_group: Unspecified
rpm_buildhost: localhost
location_href: Packages/python-dataclass-codec-0.5.10-1.src.rpm
checksum_type: sha256
description:
  dataclass_codec is a Python library that provides encoding and decoding functions for dictionaries. It allows you to easily convert Python dictionaries to JSON-compatible data structures and vice versa.



  You can install dataclass_codec using pip:

  ```
  pip install dataclass-codec
  ```



  dataclass_codec is designed to work with dictionaries, which are a common way to represent structured data in Python. You can use dataclass_codec to decode dictionaries into Python dataclasses.

  Here is an example of how to use dataclass_codec with dataclasses:

  ```python
  from dataclasses import dataclass

  from dataclass_codec import decode



  @dataclass
  class Person:
      name: str
      age: int
      city: str


  person_dict = {
      "name": "John",
      "age": 30,
      "city": "New York"
  }


  person = decode(person_dict, Person)


  print(person.name)  # Output: John
  print(person.age)   # Output: 30
  print(person.city)  # Output: New York
  ```

  In the above example, we define a dataclass `Person` using the `@dataclass` decorator. The `Person` dataclass has three attributes: `name`, `age`, and `city`. We then have a dictionary `person_dict` representing a person. By using the `decode` function from dataclass_codec, we can easily convert the dictionary into a Person object. Finally, we access the attributes of the Person object and print their values.





  You can use dataclass_codec to decode dictionaries that have nested dictionaries as values. The nested dictionaries will be decoded into nested dataclass objects.

  ```python
  from dataclasses import dataclass

  from dataclass_codec import decode



  @dataclass
  class Address:
      street: str
      city: str
      zip_code: str


  @dataclass
  class Person:
      name: str
      age: int
      address: Address


  person_dict = {
      "name": "John",
      "age": 30,
      "address": {
          "street": "123 Main St",
          "city": "New York",
          "zip_code": "10001"
      }
  }


  person = decode(person_dict, Person)


  print(person.name)                      # Output: John
  print(person.age)                       # Output: 30
  print(person.address.street)            # Output: 123 Main St
  print(person.address.city)              # Output: New York
  print(person.address.zip_code)          # Output: 10001
  ```

  In this example, we define a dataclass `Address` representing an address with attributes `street`, `city`, and `zip_code`. We also define a dataclass `Person` with attributes `name`, `age`, and `address`, where `address` is an instance of the `Address` dataclass. The dictionary `person_dict` contains a nested dictionary for the address. By using the `decode` function, we can easily convert the dictionary into a Person object with a nested Address object. Finally, we access the attributes of the Person object and its nested Address object and print their values.

  Remember to define all your dataclasses using the `@dataclass` decorator for dataclass_codec to work correctly.



  ```python
  from dataclasses import dataclass
  from typing import List, TypeVar

  from dataclass_codec import decode


  T = TypeVar('T')


  @dataclass
  class Container:
      items: List[T]


  container_dict = {
      "items": [1, 2, 3, 4, 5]
  }


  container = decode(container_dict, Container[int])


  print(container.items)  # Output: [1, 2, 3, 4, 5]
  ```

  In this example, we showcase how to decode a dictionary containing a list of generic types. We define a generic dataclass `Container` with a single attribute `items`, which is a list of generic type `T`. The dictionary `container_dict` contains a list of items `[1, 2, 3, 4, 5]`. By using the `decode` function with the type `Container[int]`, we can convert the dictionary into a `Container` object, where the list of items is preserved.

  Feel free to include this example in your readme to demonstrate how to decode a dictionary with a generic list into a corresponding dataclass object.



  The `dataclass_codec` library provides a `DecodeContext` class and a context-based approach to manage the decoding behavior using the `decode_context_scope` context manager.



  ```python
  @dataclass
  class DecodeContext:
      strict: bool = False
      primitive_cast_values: bool = True
      dataclass_unset_as_none: bool = True
      collect_errors: bool = False
  ```

  The `DecodeContext` class represents the decoding context with the following configurable options:

  - `strict` (bool): If set to `True`, the decoder raises an exception when encountering unknown fields. Defaults to `False`.
  - `primitive_cast_values` (bool): If set to `True`, the decoder attempts to cast values to their declared types. Defaults to `True`.
  - `dataclass_unset_as_none` (bool): If set to `True`, the decoder treats unset fields in dataclasses as `None`. Defaults to `True`.
  - `collect_errors` (bool): If set to `True`, the decoder collects decoding errors as a list of `(error_path, error)` tuples. Defaults to `False`.



  ```python
  @contextmanager
  def decode_context_scope(
      decode_context: DecodeContext,
  ) -> Generator[None, Any, None]:
      
  ```

  The `decode_context_scope` is a context manager that allows you to temporarily set a specific `DecodeContext` within a context block. This context manager ensures that the desired decoding behavior is applied within the block and reverts to the previous context afterward.

  Usage:

  ```python
  with decode_context_scope(DecodeContext(strict=True, primitive_cast_values=False)):
      
      
  ```

  By using the `decode_context_scope` context manager, you can easily control the decoding behavior within a specific scope, allowing you to customize options such as strict decoding, casting values, handling unset fields, and collecting errors.

  Feel free to include this section in your readme to explain the usage of `DecodeContext` and `decode_context_scope` for managing the decoding behavior within different contexts.

  Certainly! Here's an updated version of the section that includes a dataclass with a bytes property:



  The `dataclass_codec` library provides built-in support for encoding and decoding byte data, including working with bytes properties within dataclasses. You can easily encode byte data into a string representation and decode it back into its original byte form. This is useful when working with binary data or when serializing and deserializing byte data in your applications.



  To encode byte data, you can use the `encode` function provided by the `dataclass_codec` library. The `encode` function takes a byte object as input and returns its string representation.

  Example:

  ```python
  import base64
  from dataclasses import dataclass
  from dataclass_codec import encode

  @dataclass
  class MyData:
      binary_data: bytes


  my_data = MyData(binary_data=b"Hello, world!")


  encoded_data = encode(my_data)


  print(encoded_data)  # Output: '{"binary_data": "SGVsbG8sIHdvcmxkIQ=="}'
  ```

  In this example, we define a dataclass `MyData` with a `binary_data` property of type `bytes`. We create an instance of the dataclass and set the `binary_data` property to `b"Hello, world!"`. We then use the `encode` function to encode the dataclass instance, including the byte data. The resulting encoded data is `{"binary_data": "SGVsbG8sIHdvcmxkIQ=="}`. The byte data is encoded using Base64 encoding within the JSON representation of the dataclass instance.



  To decode byte data back into its original form, you can use the `decode` function provided by the `dataclass_codec` library. The `decode` function takes the encoded data as a string and the target dataclass type and returns the decoded dataclass instance.

  Example:

  ```python
  import base64
  from dataclasses import dataclass
  from dataclass_codec import decode

  @dataclass
  class MyData:
      binary_data: bytes


  decoded_data = decode({"binary_data": "SGVsbG8sIHdvcmxkIQ=="}, MyData)


  print(decoded_data.binary_data)  # Output: b"Hello, world!"
  ```

  In this example, we define the same `MyData` dataclass with a `binary_data` property of type `bytes`. We use the `decode` function to decode the encoded data `{"binary_data": "SGVsbG8sIHdvcmxkIQ=="}` back into its original dataclass form. The resulting decoded dataclass instance contains the byte data `b"Hello, world!"`.

  By leveraging the encoding and decoding capabilities provided by the `dataclass_codec` library, you can seamlessly work with byte data within dataclasses, ensuring efficient serialization and deserialization of binary data.

  Feel free to include this section in your readme to explain the process of encoding and decoding byte data, including working with bytes properties within dataclasses using the `dataclass_codec` library.



  dataclass_codec is a powerful library for decoding dictionaries into dataclasses in Python. It provides an easy and efficient way to convert data between Python objects and JSON-compatible formats. Whether you need to deserialize data for processing or manipulation purposes, dataclass_codec can simplify the process and save you time. Give it a try and see how it can enhance your data manipulation workflow.


pkgId: 232b5bd62908aa5a3a56b2a44f1bb76ece7f04961054c1e72d3a24b7062edb52
name: python-dataclass-csv
arch: src
version: 1.4.0
epoch: 0
release: 1
summary: Map CSV data into dataclasses
url: https://github.com/dfurtado/dataclass-csv
rpm_license: BSD license
rpm_group: Unspecified
rpm_buildhost: localhost
location_href: Packages/python-dataclass-csv-1.4.0-1.src.rpm
checksum_type: sha256
description:
  [![Build Status](https://travis-ci.org/dfurtado/dataclass-csv.svg?branch=master)](https://travis-ci.org/dfurtado/dataclass-csv)
  [![pypi](https://img.shields.io/pypi/v/dataclass-csv.svg)](https://pypi.python.org/pypi/dataclass-csv)
  [![Downloads](https://pepy.tech/badge/dataclass-csv)](https://pepy.tech/project/dataclass-csv)





  Dataclass CSV makes working with CSV files easier and much better than working with Dicts. It uses Python's Dataclasses to store data of every row on the CSV file and also uses type annotations which enables proper type checking and validation.




  - Use `dataclasses` instead of dictionaries to represent the rows in the CSV file.
  - Take advantage of the `dataclass` properties type annotation. `DataclassReader` use the type annotation to perform validation of the data of the CSV file.
  - Automatic type conversion. `DataclassReader` supports `str`, `int`, `float`, `complex`, `datetime` and `bool`, as well as any type whose constructor accepts a string as its single argument.
  - Helps you troubleshoot issues with the data in the CSV file. `DataclassReader` will show exactly in which line of the CSV file contain errors.
  - Extract only the data you need. It will only parse the properties defined in the `dataclass`
  - Familiar syntax. The `DataclassReader` is used almost the same way as the `DictReader` in the standard library.
  - It uses `dataclass` features that let you define metadata properties so the data can be parsed exactly the way you want.
  - Make the code cleaner. No more extra loops to convert data to the correct type, perform validation, set default values, the `DataclassReader` will do all this for you.
  - In additon of the `DataclassReader` the library also provides a `DataclassWriter` which enables creating a CSV file
  using a list of instances of a dataclass.




  ```shell
  pipenv install dataclass-csv
  ```





  First, add the necessary imports:

  ```python
  from dataclasses import dataclass

  from dataclass_csv import DataclassReader
  ```

  Assuming that we have a CSV file with the contents below:
  ```text
  firstname,email,age
  Elsa,elsa@test.com, 11
  Astor,astor@test.com, 7
  Edit,edit@test.com, 3
  Ella,ella@test.com, 2
  ```

  Let's create a dataclass that will represent a row in the CSV file above:
  ```python
  @dataclass
  class User:
      firstname: str
      email: str
      age: int
  ```

  The dataclass `User` has 3 properties, `firstname` and `email` is of type `str` and `age` is of type `int`.

  To load and read the contents of the CSV file we do the same thing as if we would be using the `DictReader` from the `csv` module in the Python's standard library. After opening the file we create an instance of the `DataclassReader` passing two arguments. The first is the `file` and the second is the dataclass that we wish to use to represent the data of every row of the CSV file. Like so:

  ```python
  with open(filename) as users_csv:
      reader = DataclassReader(users_csv, User)
      for row in reader:
          print(row)
  ```

  The `DataclassReader` internally uses the `DictReader` from the `csv` module to read the CSV file which means that you can pass the same arguments that you would pass to the `DictReader`. The complete argument list is shown below:

  ```python
  dataclass_csv.DataclassReader(
      f,
      cls,
      fieldnames=None,
      restkey=None,
      restval=None,
      dialect='excel',
      *args,
      **kwds
  )
  ```

  All keyword arguments support by `DictReader` are supported by the `DataclassReader`, with the addition of:

  `validate_header` - The `DataclassReader` will raise a `ValueError` if the CSV file cointain columns with the same name. This
  validation is performed to avoid data being overwritten. To skip this validation set `validate_header=False` when creating a
  instance of the `DataclassReader`, see an example below:

  ```python
  reader = DataclassReader(f, User, validate_header=False)
  ```

  If you run this code you should see an output like this:

  ```python
  User(firstname='Elsa', email='elsa@test.com', age=11)
  User(firstname='Astor', email='astor@test.com', age=7)
  User(firstname='Edit', email='edit@test.com', age=3)
  User(firstname='Ella', email='ella@test.com', age=2)
  ```



  One of the advantages of using the `DataclassReader` is that it makes it easy to detect when the type of data in the CSV file is not what your application's model is expecting. And, the `DataclassReader` shows errors that will help to identify the rows with problem in your CSV file.

  For example, say we change the contents of the CSV file shown in the **Getting started** section and, modify the `age` of the user Astor, let's change it to a string value:

  ```text
  Astor, astor@test.com, test
  ```

  Remember that in the dataclass `User` the `age` property is annotated with `int`. If we run the code again an exception will be raised with the message below:

  ```text
  dataclass_csv.exceptions.CsvValueError: The field `age` is defined as <class 'int'> but
  received a value of type <class 'str'>. [CSV Line number: 3]
  ```

  Note that apart from telling what the error was, the `DataclassReader` will also show which line of the CSV file contain the data with errors.



  The `DataclassReader` also handles properties with default values. Let's modify the dataclass `User` and add a default value for the field `email`:

  ```python
  from dataclasses import dataclass


  @dataclass
  class User:
      firstname: str
      email: str = 'Not specified'
      age: int
  ```

  And we modify the CSV file and remove the email for the user Astor:

  ```python
  Astor,, 7
  ```

  If we run the code we should see the output below:

  ```text
  User(firstname='Elsa', email='elsa@test.com', age=11)
  User(firstname='Astor', email='Not specified', age=7)
  User(firstname='Edit', email='edit@test.com', age=3)
  User(firstname='Ella', email='ella@test.com', age=2)
  ```

  Note that now the object for the user Astor have the default value `Not specified` assigned to the email property.

  Default values can also be set using `dataclasses.field` like so:

  ```python
  from dataclasses import dataclass, field


  @dataclass
  class User:
      firstname: str
      email: str = field(default='Not specified')
      age: int
  ```



  The mapping between a dataclass property and a column in the CSV file will be done automatically if the names match, however, there are situations that the name of the header for a column is different. We can easily tell the `DataclassReader` how the mapping should be done using the method `map`. Assuming that we have a CSV file with the contents below:

  ```text
  First Name,email,age
  Elsa,elsa@test.com, 11
  ```

  Note that now, the column is called **First Name** and not **firstname**

  And we can use the method `map`, like so:

  ```python
  reader = DataclassReader(users_csv, User)
  reader.map('First name').to('firstname')
  ```

  Now the DataclassReader will know how to extract the data from the column **First Name** and add it to the to dataclass property **firstname**



  At the moment the `DataclassReader` support `int`, `str`, `float`, `complex`, `datetime`, and `bool`. When defining a `datetime` property, it is necessary to use the `dateformat` decorator, for example:

  ```python
  from dataclasses import dataclass
  from datetime import datetime

  from dataclass_csv import DataclassReader, dateformat


  @dataclass
  @dateformat('%Y/%m/%d')
  class User:
      name: str
      email: str
      birthday: datetime


  if __name__ == '__main__':

      with open('users.csv') as f:
          reader = DataclassReader(f, User)
          for row in reader:
              print(row)
  ```

  Assuming that the CSV file have the following contents:

  ```text
  name,email,birthday
  Edit,edit@test.com,2018/11/23
  ```

  The output would look like this:

  ```text
  User(name='Edit', email='edit@test.com', birthday=datetime.datetime(2018, 11, 23, 0, 0))
  ```



  It is important to note that the `dateformat` decorator will define the date format that will be used to parse date to all properties
  in the class. Now there are situations where the data in a CSV file contains two or more columns with date values in different formats. It is possible
  to set a format specific for every property using the `dataclasses.field`. Let's say that we now have a CSV file with the following contents:

  ```text
  name,email,birthday, create_date
  Edit,edit@test.com,2018/11/23,2018/11/23 10:43
  ```

  As you can see the `create_date` contains time information as well.

  The `dataclass` User can be defined like this:

  ```python
  from dataclasses import dataclass, field
  from datetime import datetime

  from dataclass_csv import DataclassReader, dateformat


  @dataclass
  @dateformat('%Y/%m/%d')
  class User:
      name: str
      email: str
      birthday: datetime
      create_date: datetime = field(metadata={'dateformat': '%Y/%m/%d %H:%M'})
  ```

  Note that the format for the `birthday` field was not speficied using the `field` metadata. In this case the format specified in the `dateformat`
  decorator will be used.



  When defining a property of type `str` in the `dataclass`, the `DataclassReader` will treat values with only white spaces as invalid. To change this
  behavior, there is a decorator called `@accept_whitespaces`. When decorating the class with the `@accept_whitespaces` all the properties in the class
  will accept values with only white spaces.

  For example:

  ```python
  from dataclass_csv import DataclassReader, accept_whitespaces

  @accept_whitespaces
  @dataclass
  class User:
      name: str
      email: str
      birthday: datetime
      created_at: datetime
  ```

  If you need a specific field to accept white spaces, you can set the property `accept_whitespaces` in the field's metadata, like so:

  ```python
  @dataclass
  class User:
      name: str
      email: str = field(metadata={'accept_whitespaces': True})
      birthday: datetime
      created_at: datetime
  ```



  You can use any type for a field as long as its constructor accepts a string:

  ```python
  class SSN:
      def __init__(self, val):
          if re.match(r"\d{9}", val):
              self.val = f"{val[0:3]}-{val[3:5]}-{val[5:9]}"
          elif re.match(r"\d{3}-\d{2}-\d{4}", val):
              self.val = val
          else:
              raise ValueError(f"Invalid SSN: {val!r}")


  @dataclasses.dataclass
  class User:
      name: str
      ssn: SSN
  ```




  Reading a CSV file using the `DataclassReader` is great and gives us the type-safety of Python's dataclasses and type annotation, however, there are situations where we would like to use dataclasses for creating CSV files, that's where the `DataclassWriter` comes in handy.

  Using the `DataclassWriter` is quite simple. Given that we have a dataclass `User`:

  ```python
  from dataclasses import dataclass


  @dataclass
  class User:
      firstname: str
      lastname: str
      age: int
  ```

  And in your program we have a list of users:

  ```python

  users = [
      User(firstname="John", lastname="Smith", age=40),
      User(firstname="Daniel", lastname="Nilsson", age=10),
      User(firstname="Ella", "Fralla", age=4)
  ]
  ```

  In order to create a CSV using the `DataclassWriter` import it from `dataclass_csv`:

  ```python
  from dataclass_csv import DataclassWriter
  ```

  Initialize it with the required arguments and call the method `write`:

  ```python
  with open("users.csv", "w") as f:
      w = DataclassWriter(f, users, User)
      w.write()
  ```

  That's it! Let's break down the snippet above.

  First, we open a file called `user.csv` for writing. After that, an instance of the `DataclassWriter` is created. To create a `DataclassWriter` we need to pass the `file`, the list of `User` instances, and lastly, the type, which in this case is `User`.

  The type is required since the writer uses it when trying to figure out the CSV header. By default, it will use the names of the
  properties defined in the dataclass, in the case of the dataclass `User` the title of each column
  will be `firstname`, `lastname` and `age`.

  See below the CSV created out of a list of `User`:

  ```text
  firstname,lastname,age
  John,Smith,40
  Daniel,Nilsson,10
  Ella,Fralla,4
  ```

  The `DataclassWriter` also takes a `**fmtparams` which accepts the same parameters as the `csv.writer`, for more
  information see: https://docs.python.org/3/library/csv.html#csv-fmt-params

  Now, there are situations where we don't want to write the CSV header. In this case, the method `write` of
  the `DataclassWriter` accepts an extra argument, called `skip_header`. The default value is `False` and when set to
  `True` it will skip the header.



  As previously mentioned the `DataclassWriter` uses the names of the properties defined in the dataclass as the CSV header titles, however,
  depending on your use case it makes sense to change it. The `DataclassWriter` has a `map` method just for this purpose.

   Using the `User` dataclass with the properties `firstname`, `lastname` and `age`. The snippet below shows how to change `firstname` to `First name` and `lastname` to `Last name`:

   ```python
   with open("users.csv", "w") as f:
      w = DataclassWriter(f, users, User)

      
      w.map("firstname").to("First name")
      w.map("lastname").to("Last name")

      w.write()
   ```

   The CSV output of the snippet above will be:

  ```text
  First name,Last name,age
  John,Smith,40
  Daniel,Nilsson,10
  Ella,Fralla,4
  ```



  Copyright (c) 2018 Daniel Furtado. Code released under BSD 3-clause license



  This package was created with [Cookiecutter](https://github.com/audreyr/cookiecutter) and the [audreyr/cookiecutter-pypackage](https://github.com/audreyr/cookiecutter-pypackage) project template.






  * First release on PyPI.



  * Documentation fixes.



  * Documentation fixes.



  * Bug fixes
  * Removed the requirement of setting the dataclass init to `True`



  * Support for parsing datetime values.
  * Better handling when default values are set to `None`



  * Added support for reader default values from the default property of the `dataclasses.field`.
  * Added support for allowing string values with only white spaces in a class level using the `@accept_whitespaces` decorator or through the `dataclasses.field` metadata.
  * Added support for specifying date format using the `dataclasses.field` metadata.



  * Added support for default values from `default_factory` in the field's metadata. This allows adding mutable default values to the dataclass properties.



  * When a data does not pass validation it shows the line number in the CSV file where the data contain errors.
  * Improved error handling.
  * Changed the usage of the `@accept_whitespaces` decorator.
  * Updated documentation.



  * Fixed issue when parsing headers on a CSV file with trailing white spaces.



  * Added support for boolean values.
  * Docstrings



  * Documentation fixes.



  * Documentation fixes.



  * Handle properties with init set to False
  * Handle Option type annotation



  * Introduction of a DataclassWriter
  * Added type hinting to external API
  * Documentation updates
  * Bug fixes



  * Included stub files
  * check if the CSV file has duplicated header values
  * Fixed issues #22 and #33
  * code cleanup



  * Bug fixes
  * Support for date types


pkgId: adf5dfa481f898034f8c98322bf23a586366d25bab771d1e1eb8fcf4759995f6
name: python-dataclass-dict-convert
arch: src
version: 1.7.3
epoch: 0
release: 1
summary: Convert between Dataclasses and dict/json
url: https://gitlab.ilabt.imec.be/wvdemeer/dataclass-dict-convert
rpm_license: MIT
rpm_group: Unspecified
rpm_buildhost: localhost
location_href: Packages/python-dataclass-dict-convert-1.7.3-1.src.rpm
checksum_type: sha256
description:
  This library converts between python [dataclasses](https://docs.python.org/3/library/dataclasses.html#dataclasses.dataclass) and dicts (and json).

  It was created because when using the [dataclasses-json](https://pypi.org/project/dataclasses-json/) library for my use case, I ran into limitations and performance issues.
  (There's also [typed-json-dataclass](https://pypi.org/project/typed-json-dataclass) but I haven't evaluated that library.)

  Since creating this library, I've discovered [Pydentic](https://pypi.org/project/pydentic/), which is a much more professional library, that in 99% of cases will be much more suitable than this library.
  So I strongly recommend using Pydentic. If you use `dataclass-dict-convert`, beware that it is poorly maintained, not very well documented, may contain some bugs, and has some strange edge cases where it doesn't work.

  `dataclass-dict-convert` supports lists, optionals, dicts, enums, nested dataclasses, etc.
  It handles dates using RFC3339 (and enforces timezones and timezone aware `datetime`).

  Example:

  ```python
  from dataclasses import dataclass
  from stringcase import camelcase
  from typing import Optional, List

  from dataclass_dict_convert import dataclass_dict_convert


  @dataclass_dict_convert(dict_letter_case=camelcase)
  @dataclass(frozen=True)
  class TestB:
      an_int: int
      a_str: str
      a_float: float
      a_bool: bool


  @dataclass_dict_convert(dict_letter_case=camelcase)
  @dataclass(frozen=True)
  class Test:
      nestedClass: TestB
      nestedInOpt: Optional[TestB]
      nestedInList: List[TestB]


  the_instanceB1 = TestB(1, 'foo', 0.1, True)
  the_instanceB2 = TestB(2, 'bar', 0.2, False)
  the_instanceB3 = TestB(3, 'baz', 0.3, True)
  the_instanceB4 = TestB(4, 'huh', 0.4, False)
  the_instance = Test(the_instanceB1, the_instanceB2, [the_instanceB3, the_instanceB4])
  the_dict = {
      'nestedClass': {'anInt': 1, 'aStr': 'foo', 'aFloat': 0.1, 'aBool': True, },
      'nestedInOpt': {'anInt': 2, 'aStr': 'bar', 'aFloat': 0.2, 'aBool': False, },
      'nestedInList': [
          {'anInt': 3, 'aStr': 'baz', 'aFloat': 0.3, 'aBool': True, },
          {'anInt': 4, 'aStr': 'huh', 'aFloat': 0.4, 'aBool': False, },
      ],
  }

  expected = the_dict
  actual = the_instance.to_dict()
  assert actual == expected

  expected = the_instance
  actual = Test.from_dict(the_dict)
  assert actual == expected
  ```

  The library also includes:
  - RFC3339 tools (the default format for converting datetime to string),
  - dataclass type checking tools
  - dataclass copy method generator
  - dataclass multiline repr (replace auto generated repr for dataclasses by a multiline version)

  Links:
  - Gitlab: https://gitlab.ilabt.imec.be/wvdemeer/dataclass-dict-convert
  - PyPi: https://pypi.org/project/dataclass-dict-convert/


pkgId: 3eb19979b17b0bd2c86d44a1edcf3aa870eab4d14d39bffddbf429f563852d61
name: python-dataclassabc
arch: src
version: 0.0.12
epoch: 0
release: 1
url: https://github.com/MichaelSchneeberger/dataclass-abc
rpm_license: None
rpm_group: Unspecified
rpm_buildhost: localhost
location_href: Packages/python-dataclassabc-0.0.12-1.src.rpm
checksum_type: sha256
summary:
  A Python library that allows you to define abstract properties for dataclasses, bridging the gap between abstract base classes (ABCs) and dataclasses.

description:
  A Python library that allows you to define abstract properties for dataclasses, bridging the gap between abstract base classes (ABCs) and dataclasses.



  You can install dataclass-abc using pip:

  ```bash
  pip install dataclassabc
  ```



  The `dataclassabc` decorator enables the use of abstract properties within dataclasses.
  It resolves abstract properties defined in an abstract base class (ABC) and enforces their implementation through fields in the derived dataclass.



  Here's how you can define an abstract property in a base class and implement it in a derived dataclass:

  ``` python
  from abc import ABC, abstractmethod

  from dataclassabc import dataclassabc


  class A(ABC):
      @property
      @abstractmethod
      def name(self) -> str: ...


  @dataclassabc(frozen=True)
  class B(A):
      
      name: str
  ```

  Using the standard `dataclass` decorator from the `dataclasses` module to implement abstract properties will result in a TypeError, as shown below:

  ``` python
  from abc import ABC, abstractmethod

  from dataclasses import dataclass

  @dataclass(frozen=True)
  class B(A):
      name: str


  b = B(name='A')
  ```




  You can define mutable abstract properties by using the `@property` and `@name.setter` decorators in the abstract class. The following example demonstrates how to define and set a mutable property:



  ``` python
  from abc import ABC, abstractmethod

  from dataclassabc import dataclassabc

  class A(ABC):
      @property
      @abstractmethod
      def name(self) -> str: ...

      @name.setter
      @abstractmethod
      def name(self, val: str): ...

  @dataclassabc
  class B(A):
      name: str

  b = B(name='A')

  b.name = 'B'


  print(f'{b=}')
  ```

  <!-- ## References -->

  <!-- * [Question on Stackoverflow](https://stackoverflow.com/questions/51079503/dataclasses-and-property-decorator/59824846#59824846) -->


pkgId: 0e9d2ab1202f11bc461baa656b3d2498295dc8e9a29dd6a1da83fe402dbe9136
name: python-dataclasses-avroschema
arch: src
version: 0.63.3
epoch: 0
release: 1
summary: Generate Avro Schemas from Python classes. Serialize/Deserialize python instances with avro schemas
url: https://pypi.org/project/dataclasses-avroschema/
rpm_license: MIT
rpm_group: Unspecified
rpm_buildhost: localhost
location_href: Packages/python-dataclasses-avroschema-0.63.3-1.src.rpm
checksum_type: sha256
description:
  Generate [avro schemas](https://avro.apache.org/docs/1.8.2/spec.html) from python dataclasses. [Code generation](https://marcosschroh.github.io/dataclasses-avroschema/model_generator/) from avro schemas. [Serialize/Deserialize](https://marcosschroh.github.io/dataclasses-avroschema/serialization/) python instances with avro schemas

  [![Tests](https://github.com/marcosschroh/dataclasses-avroschema/actions/workflows/tests.yaml/badge.svg)](https://github.com/marcosschroh/dataclasses-avroschema/actions/workflows/tests.yaml)
  [![GitHub license](https://img.shields.io/github/license/marcosschroh/dataclasses-avroschema.svg)](https://github.com/marcosschroh/dataclasses-avroschema/blob/master/LICENSE)
  [![codecov](https://codecov.io/gh/marcosschroh/dataclasses-avroschema/branch/master/graph/badge.svg)](https://codecov.io/gh/marcosschroh/dataclasses-avroschema)
  ![python version](https://img.shields.io/badge/python-3.8%2B-yellowgreen)



  `python 3.8+`



  with `pip` or `poetry`:

  `pip install dataclasses-avroschema` or `poetry add dataclasses-avroschema`



  - [pydantic](https://docs.pydantic.dev/): `pip install 'dataclasses-avroschema[pydantic]'` or `poetry add dataclasses-avroschema --extras "pydantic"`
  - [faust-streaming](https://github.com/faust-streaming/faust): `pip install 'dataclasses-avroschema[faust]'` or `poetry add dataclasses-avroschema --extras "faust"`
  - [faker](https://github.com/joke2k/faker): `pip install 'dataclasses-avroschema[faker]'` or `poetry add dataclasses-avroschema --extras "faker"`
  - [dc-avro](https://marcosschroh.github.io/dc-avro/): `pip install 'dataclasses-avroschema[cli]'` or `poetry add dataclasses-avroschema --with cli`

  *Note*: You can install all extra dependencies with `pip install dataclasses-avroschema[faust,pydantic,faker,cli]` or `poetry add dataclasses-avroschema --extras "pydantic faust faker cli"`



  https://marcosschroh.github.io/dataclasses-avroschema/





  ```python
  from dataclasses import dataclass
  import enum

  import typing

  from dataclasses_avroschema import AvroModel


  class FavoriteColor(str, enum.Enum):
      BLUE = "BLUE"
      YELLOW = "YELLOW"
      GREEN = "GREEN"


  @dataclass
  class User(AvroModel):
      "An User"
      name: str
      age: int
      pets: typing.List[str]
      accounts: typing.Dict[str, int]
      favorite_colors: FavoriteColor
      country: str = "Argentina"
      address: typing.Optional[str] = None

      class Meta:
          namespace = "User.v1"
          aliases = ["user-v1", "super user"]


  print(User.avro_schema())


















  assert User.avro_schema_to_python() == {
      "type": "record",
      "name": "User",
      "doc": "An User",
      "namespace": "User.v1",
      "aliases": ["user-v1", "super user"],
      "fields": [
          {"name": "name", "type": "string"},
          {"name": "age", "type": "long"},
          {"name": "pets", "type": {"type": "array", "items": "string", "name": "pet"}},
          {"name": "accounts", "type": {"type": "map", "values": "long", "name": "account"}},
          {"name": "favorite_colors", "type": {"type": "enum", "name": "FavoriteColor", "symbols": ["BLUE", "YELLOW", "GREEN"]}},
          {"name": "country", "type": "string", "default": "Argentina"},
          {"name": "address", "type": ["null", "string"], "default": None}
      ],
  }
  ```



  For serialization is neccesary to use python class/dataclasses instance

  ```python
  from dataclasses import dataclass

  import typing

  from dataclasses_avroschema import AvroModel


  @dataclass
  class Address(AvroModel):
      "An Address"
      street: str
      street_number: int


  @dataclass
  class User(AvroModel):
      "User with multiple Address"
      name: str
      age: int
      addresses: typing.List[Address]

  address_data = {
      "street": "test",
      "street_number": 10,
  }


  address = Address(**address_data)

  data_user = {
      "name": "john",
      "age": 20,
      "addresses": [address],
  }


  user = User(**data_user)


  assert user.serialize() == b"\x08john(\x02\x08test\x14\x00"

  assert user.serialize(
      serialization_type="avro-json"
  ) == b'{"name": "john", "age": 20, "addresses": [{"street": "test", "street_number": 10}]}'


  assert user.to_json() == '{"name": "john", "age": 20, "addresses": [{"street": "test", "street_number": 10}]}'


  assert user.to_dict() == {
      "name": "john",
      "age": 20,
      "addresses": [
          {"street": "test", "street_number": 10}
      ]
  }
  ```



  Deserialization could take place with an instance dataclass or the dataclass itself. Can return the dict representation or a new class instance

  ```python
  import typing
  import dataclasses

  from dataclasses_avroschema import AvroModel


  @dataclasses.dataclass
  class Address(AvroModel):
      "An Address"
      street: str
      street_number: int

  @dataclasses.dataclass
  class User(AvroModel):
      "User with multiple Address"
      name: str
      age: int
      addresses: typing.List[Address]

  avro_binary = b"\x08john(\x02\x08test\x14\x00"
  avro_json_binary = b'{"name": "john", "age": 20, "addresses": [{"street": "test", "street_number": 10}]}'


  assert User.deserialize(avro_binary) == User(
      name='john',
      age=20,
      addresses=[Address(street='test', street_number=10)]
  )


  assert User.deserialize(avro_binary, create_instance=False) == {
      "name": "john",
      "age": 20,
      "addresses": [
          {"street": "test", "street_number": 10}
      ]
  }


  assert User.deserialize(avro_json_binary, serialization_type="avro-json") == User(
      name='john',
      age=20,
      addresses=[Address(street='test', street_number=10)]
  )


  assert User.deserialize(
      avro_json_binary,
      serialization_type="avro-json",
      create_instance=False
  ) == {"name": "john", "age": 20, "addresses": [{"street": "test", "street_number": 10}]}
  ```



  To add `dataclasses-avroschema` functionality to `pydantic` you only need to replace `BaseModel` by `AvroBaseModel`:

  ```python
  import typing
  import enum

  from dataclasses_avroschema.pydantic import AvroBaseModel

  from pydantic import Field, ValidationError


  class FavoriteColor(str, enum.Enum):
      BLUE = "BLUE"
      YELLOW = "YELLOW"
      GREEN = "GREEN"


  class UserAdvance(AvroBaseModel):
      name: str
      age: int
      pets: typing.List[str] = Field(default_factory=lambda: ["dog", "cat"])
      accounts: typing.Dict[str, int] = Field(default_factory=lambda: {"key": 1})
      has_car: bool = False
      favorite_colors: FavoriteColor = FavoriteColor.BLUE
      country: str = "Argentina"
      address: typing.Optional[str] = None

      class Meta:
          schema_doc = False


  assert UserAdvance.avro_schema_to_python() == {
      "type": "record",
      "name": "UserAdvance",
      "fields": [
          {"name": "name", "type": "string"},
          {"name": "age", "type": "long"},
          {"name": "pets", "type": {"type": "array", "items": "string", "name": "pet"}, "default": ["dog", "cat"]},
          {"name": "accounts", "type": {"type": "map", "values": "long", "name": "account"}, "default": {"key": 1}},
          {"name": "has_car", "type": "boolean", "default": False},{"name": "favorite_colors", "type": {"type": "enum", "name": "FavoriteColor", "symbols": ["BLUE", "YELLOW", "GREEN"]}, "default": "BLUE"},
          {"name": "country", "type": "string", "default": "Argentina"}, {"name": "address", "type": ["null", "string"], "default": None}
      ]
  }

  print(UserAdvance.json_schema())


















  user = UserAdvance(name="bond", age=50)


  assert user.dict() == {
      'name': 'bond',
      'age': 50,
      'pets': ['dog', 'cat'],
      'accounts': {'key': 1},
      'has_car': False,
      'favorite_colors': FavoriteColor.BLUE,
      'country': 'Argentina',
      'address': None
  }


  print(user.json())

  assert user.json() == '{"name":"bond","age":50,"pets":["dog","cat"],"accounts":{"key":1},"has_car":false,"favorite_colors":"BLUE","country":"Argentina","address":null}'


  try:
      user = UserAdvance(name="bond")
  except ValidationError as exc:
      ...


  event = user.serialize()
  assert event == b'\x08bondd\x04\x06dog\x06cat\x00\x02\x06key\x02\x00\x00\x00\x12Argentina\x00'

  assert UserAdvance.deserialize(data=event) == UserAdvance(
      name='bond',
      age=50,
      pets=['dog', 'cat'],
      accounts={'key': 1},
      has_car=False,
      favorite_colors=FavoriteColor.BLUE,
      country='Argentina',
      address=None
  )
  ```



  Under [examples](https://github.com/marcosschroh/dataclasses-avroschema/tree/master/examples) folder you can find 3 differents kafka examples, one with [aiokafka](https://github.com/aio-libs/aiokafka) (`async`) showing the simplest use case when a `AvroModel` instance is serialized and sent it thorught kafka, and the event is consumed.
  The other two examples are `sync` using the [kafka-python](https://github.com/dpkp/kafka-python) driver, where the `avro-json` serialization and `schema evolution` (`FULL` compatibility) is shown.
  Also, there are two `redis` examples using `redis streams` with [walrus](https://github.com/coleifer/walrus) and [redisgears-py](https://github.com/RedisGears/redisgears-py)



  [Dataclasses Avro Schema](https://github.com/marcosschroh/dataclasses-avroschema) also includes a `factory` feature, so you can generate `fast` python instances and use them, for example, to test your data streaming pipelines. Instances can be generated using the `fake` method.

  *Note*: This feature is not enabled by default and requires you have the `faker` extra installed. You may install it with `pip install 'dataclasses-avroschema[faker]'`

  ```python
  import typing
  import dataclasses

  from dataclasses_avroschema import AvroModel


  @dataclasses.dataclass
  class Address(AvroModel):
      "An Address"
      street: str
      street_number: int


  @dataclasses.dataclass
  class User(AvroModel):
      "User with multiple Address"
      name: str
      age: int
      addresses: typing.List[Address]


  Address.fake()


  User.fake()

  ```



  - [x] Primitive types: int, long, double, float, boolean, string and null support
  - [x] Complex types: enum, array, map, fixed, unions and records support
  - [x] `typing.Annotated` supported
  - [x] `typing.Literal` supported
  - [x] Logical Types: date, time (millis and micro), datetime (millis and micro), uuid support
  - [x] Schema relations (oneToOne, oneToMany)
  - [x] Recursive Schemas
  - [x] Generate Avro Schemas from `faust.Record`
  - [x] Instance serialization correspondent to `avro schema` generated
  - [x] Data deserialization. Return python dict or class instance
  - [x] Generate json from python class instance
  - [x] Case Schemas
  - [x] Generate models from `avsc` files
  - [x] Examples of integration with `kafka` drivers: [aiokafka](https://github.com/aio-libs/aiokafka), [kafka-python](https://github.com/dpkp/kafka-python)
  - [x] Example of integration  with `redis` drivers: [walrus](https://github.com/coleifer/walrus) and [redisgears-py](https://github.com/RedisGears/redisgears-py)
  - [x] Factory instances
  - [x] [Pydantic](https://pydantic-docs.helpmanual.io/) integration



  [Poetry](https://python-poetry.org/docs/) is needed to install the dependencies and develope locally

  1. Install dependencies: `poetry install --all-extras`
  2. Code linting: `./scripts/format`
  3. Run tests: `./scripts/test`
  4. Tests documentation: `./scripts/test-documentation`

  For commit messages we use [commitizen](https://commitizen-tools.github.io/commitizen/) in order to standardize a way of committing rules


pkgId: 0a1e1bbff23bf46b6e5909de852fba4db73c253b4c7641331415e3917df9537d
name: python-dataclasses-avroschema
arch: src
version: 0.65.1
epoch: 0
release: 1
summary: Generate Avro Schemas from Python classes. Serialize/Deserialize python instances with avro schemas
url: https://pypi.org/project/dataclasses-avroschema/
rpm_license: MIT
rpm_group: Unspecified
rpm_buildhost: localhost
location_href: Packages/python-dataclasses-avroschema-0.65.1-1.src.rpm
checksum_type: sha256
description:
  Generate [avro schemas](https://avro.apache.org/docs/1.8.2/spec.html) from python dataclasses, [Pydantic](https://docs.pydantic.dev/latest/) models and [Faust](https://faust-streaming.github.io/faust/) Records. [Code generation](https://marcosschroh.github.io/dataclasses-avroschema/model_generator/) from avro schemas. [Serialize/Deserialize](https://marcosschroh.github.io/dataclasses-avroschema/serialization/) python instances with avro schemas

  [![Tests](https://github.com/marcosschroh/dataclasses-avroschema/actions/workflows/tests.yaml/badge.svg)](https://github.com/marcosschroh/dataclasses-avroschema/actions/workflows/tests.yaml)
  [![GitHub license](https://img.shields.io/github/license/marcosschroh/dataclasses-avroschema.svg)](https://github.com/marcosschroh/dataclasses-avroschema/blob/master/LICENSE)
  [![codecov](https://codecov.io/gh/marcosschroh/dataclasses-avroschema/branch/master/graph/badge.svg)](https://codecov.io/gh/marcosschroh/dataclasses-avroschema)
  ![python version](https://img.shields.io/badge/python-3.9%2B-yellowgreen)



  `python 3.9+`



  with `pip` or `poetry`:

  `pip install dataclasses-avroschema` or `poetry add dataclasses-avroschema`



  - [pydantic](https://docs.pydantic.dev/): `pip install 'dataclasses-avroschema[pydantic]'` or `poetry add dataclasses-avroschema --extras "pydantic"`
  - [faust-streaming](https://github.com/faust-streaming/faust): `pip install 'dataclasses-avroschema[faust]'` or `poetry add dataclasses-avroschema --extras "faust"`
  - [faker](https://github.com/joke2k/faker): `pip install 'dataclasses-avroschema[faker]'` or `poetry add dataclasses-avroschema --extras "faker"`
  - [dc-avro](https://marcosschroh.github.io/dc-avro/): `pip install 'dataclasses-avroschema[cli]'` or `poetry add dataclasses-avroschema --with cli`

  *Note*: You can install all extra dependencies with `pip install dataclasses-avroschema[faust,pydantic,faker,cli]` or `poetry add dataclasses-avroschema --extras "pydantic faust faker cli"`



  https://marcosschroh.github.io/dataclasses-avroschema/





  ```python
  from dataclasses import dataclass
  import enum

  import typing

  from dataclasses_avroschema import AvroModel


  class FavoriteColor(str, enum.Enum):
      BLUE = "BLUE"
      YELLOW = "YELLOW"
      GREEN = "GREEN"


  @dataclass
  class User(AvroModel):
      "An User"
      name: str
      age: int
      pets: typing.List[str]
      accounts: typing.Dict[str, int]
      favorite_colors: FavoriteColor
      country: str = "Argentina"
      address: typing.Optional[str] = None

      class Meta:
          namespace = "User.v1"
          aliases = ["user-v1", "super user"]


  print(User.avro_schema())


















  assert User.avro_schema_to_python() == {
      "type": "record",
      "name": "User",
      "doc": "An User",
      "namespace": "User.v1",
      "aliases": ["user-v1", "super user"],
      "fields": [
          {"name": "name", "type": "string"},
          {"name": "age", "type": "long"},
          {"name": "pets", "type": {"type": "array", "items": "string", "name": "pet"}},
          {"name": "accounts", "type": {"type": "map", "values": "long", "name": "account"}},
          {"name": "favorite_colors", "type": {"type": "enum", "name": "FavoriteColor", "symbols": ["BLUE", "YELLOW", "GREEN"]}},
          {"name": "country", "type": "string", "default": "Argentina"},
          {"name": "address", "type": ["null", "string"], "default": None}
      ],
  }
  ```



  For serialization is neccesary to use python class/dataclasses instance

  ```python
  from dataclasses import dataclass

  import typing

  from dataclasses_avroschema import AvroModel


  @dataclass
  class Address(AvroModel):
      "An Address"
      street: str
      street_number: int


  @dataclass
  class User(AvroModel):
      "User with multiple Address"
      name: str
      age: int
      addresses: typing.List[Address]

  address_data = {
      "street": "test",
      "street_number": 10,
  }


  address = Address(**address_data)

  data_user = {
      "name": "john",
      "age": 20,
      "addresses": [address],
  }


  user = User(**data_user)


  assert user.serialize() == b"\x08john(\x02\x08test\x14\x00"

  assert user.serialize(
      serialization_type="avro-json"
  ) == b'{"name": "john", "age": 20, "addresses": [{"street": "test", "street_number": 10}]}'


  assert user.to_json() == '{"name": "john", "age": 20, "addresses": [{"street": "test", "street_number": 10}]}'


  assert user.to_dict() == {
      "name": "john",
      "age": 20,
      "addresses": [
          {"street": "test", "street_number": 10}
      ]
  }
  ```



  Deserialization could take place with an instance dataclass or the dataclass itself. Can return the dict representation or a new class instance

  ```python
  import typing
  import dataclasses

  from dataclasses_avroschema import AvroModel


  @dataclasses.dataclass
  class Address(AvroModel):
      "An Address"
      street: str
      street_number: int

  @dataclasses.dataclass
  class User(AvroModel):
      "User with multiple Address"
      name: str
      age: int
      addresses: typing.List[Address]

  avro_binary = b"\x08john(\x02\x08test\x14\x00"
  avro_json_binary = b'{"name": "john", "age": 20, "addresses": [{"street": "test", "street_number": 10}]}'


  assert User.deserialize(avro_binary) == User(
      name='john',
      age=20,
      addresses=[Address(street='test', street_number=10)]
  )


  assert User.deserialize(avro_binary, create_instance=False) == {
      "name": "john",
      "age": 20,
      "addresses": [
          {"street": "test", "street_number": 10}
      ]
  }


  assert User.deserialize(avro_json_binary, serialization_type="avro-json") == User(
      name='john',
      age=20,
      addresses=[Address(street='test', street_number=10)]
  )


  assert User.deserialize(
      avro_json_binary,
      serialization_type="avro-json",
      create_instance=False
  ) == {"name": "john", "age": 20, "addresses": [{"street": "test", "street_number": 10}]}
  ```



  To add `dataclasses-avroschema` functionality to `pydantic` you only need to replace `BaseModel` by `AvroBaseModel`:

  ```python
  import typing
  import enum

  from dataclasses_avroschema.pydantic import AvroBaseModel

  from pydantic import Field, ValidationError


  class FavoriteColor(str, enum.Enum):
      BLUE = "BLUE"
      YELLOW = "YELLOW"
      GREEN = "GREEN"


  class UserAdvance(AvroBaseModel):
      name: str
      age: int
      pets: typing.List[str] = Field(default_factory=lambda: ["dog", "cat"])
      accounts: typing.Dict[str, int] = Field(default_factory=lambda: {"key": 1})
      has_car: bool = False
      favorite_colors: FavoriteColor = FavoriteColor.BLUE
      country: str = "Argentina"
      address: typing.Optional[str] = None

      class Meta:
          schema_doc = False


  assert UserAdvance.avro_schema_to_python() == {
      "type": "record",
      "name": "UserAdvance",
      "fields": [
          {"name": "name", "type": "string"},
          {"name": "age", "type": "long"},
          {"name": "pets", "type": {"type": "array", "items": "string", "name": "pet"}, "default": ["dog", "cat"]},
          {"name": "accounts", "type": {"type": "map", "values": "long", "name": "account"}, "default": {"key": 1}},
          {"name": "has_car", "type": "boolean", "default": False},{"name": "favorite_colors", "type": {"type": "enum", "name": "FavoriteColor", "symbols": ["BLUE", "YELLOW", "GREEN"]}, "default": "BLUE"},
          {"name": "country", "type": "string", "default": "Argentina"}, {"name": "address", "type": ["null", "string"], "default": None}
      ]
  }

  print(UserAdvance.json_schema())


















  user = UserAdvance(name="bond", age=50)


  assert user.dict() == {
      'name': 'bond',
      'age': 50,
      'pets': ['dog', 'cat'],
      'accounts': {'key': 1},
      'has_car': False,
      'favorite_colors': FavoriteColor.BLUE,
      'country': 'Argentina',
      'address': None
  }


  print(user.json())

  assert user.json() == '{"name":"bond","age":50,"pets":["dog","cat"],"accounts":{"key":1},"has_car":false,"favorite_colors":"BLUE","country":"Argentina","address":null}'


  try:
      user = UserAdvance(name="bond")
  except ValidationError as exc:
      ...


  event = user.serialize()
  assert event == b'\x08bondd\x04\x06dog\x06cat\x00\x02\x06key\x02\x00\x00\x00\x12Argentina\x00'

  assert UserAdvance.deserialize(data=event) == UserAdvance(
      name='bond',
      age=50,
      pets=['dog', 'cat'],
      accounts={'key': 1},
      has_car=False,
      favorite_colors=FavoriteColor.BLUE,
      country='Argentina',
      address=None
  )
  ```



  Under [examples](https://github.com/marcosschroh/dataclasses-avroschema/tree/master/examples) folder you can find 3 differents kafka examples, one with [aiokafka](https://github.com/aio-libs/aiokafka) (`async`) showing the simplest use case when a `AvroModel` instance is serialized and sent it thorught kafka, and the event is consumed.
  The other two examples are `sync` using the [kafka-python](https://github.com/dpkp/kafka-python) driver, where the `avro-json` serialization and `schema evolution` (`FULL` compatibility) is shown.
  Also, there are two `redis` examples using `redis streams` with [walrus](https://github.com/coleifer/walrus) and [redisgears-py](https://github.com/RedisGears/redisgears-py)



  [Dataclasses Avro Schema](https://github.com/marcosschroh/dataclasses-avroschema) also includes a `factory` feature, so you can generate `fast` python instances and use them, for example, to test your data streaming pipelines. Instances can be generated using the `fake` method.

  *Note*: This feature is not enabled by default and requires you have the `faker` extra installed. You may install it with `pip install 'dataclasses-avroschema[faker]'`

  ```python
  import typing
  import dataclasses

  from dataclasses_avroschema import AvroModel


  @dataclasses.dataclass
  class Address(AvroModel):
      "An Address"
      street: str
      street_number: int


  @dataclasses.dataclass
  class User(AvroModel):
      "User with multiple Address"
      name: str
      age: int
      addresses: typing.List[Address]


  Address.fake()


  User.fake()

  ```



  - [x] Primitive types: int, long, double, float, boolean, string and null support
  - [x] Complex types: enum, array, map, fixed, unions and records support
  - [x] `typing.Annotated` supported
  - [x] `typing.Literal` supported
  - [x] Logical Types: date, time (millis and micro), datetime (millis and micro), uuid support
  - [x] Schema relations (oneToOne, oneToMany)
  - [x] Recursive Schemas
  - [x] Generate Avro Schemas from `faust.Record`
  - [x] Instance serialization correspondent to `avro schema` generated
  - [x] Data deserialization. Return python dict or class instance
  - [x] Generate json from python class instance
  - [x] Case Schemas
  - [x] Generate models from `avsc` files
  - [x] Examples of integration with `kafka` drivers: [aiokafka](https://github.com/aio-libs/aiokafka), [kafka-python](https://github.com/dpkp/kafka-python)
  - [x] Example of integration  with `redis` drivers: [walrus](https://github.com/coleifer/walrus) and [redisgears-py](https://github.com/RedisGears/redisgears-py)
  - [x] Factory instances
  - [x] [Pydantic](https://pydantic-docs.helpmanual.io/) integration



  [Poetry](https://python-poetry.org/docs/) is needed to install the dependencies and develope locally

  1. Install dependencies: `poetry install --all-extras`
  2. Code linting: `./scripts/format`
  3. Run tests: `./scripts/test`
  4. Tests documentation: `./scripts/test-documentation`

  For commit messages we use [commitizen](https://commitizen-tools.github.io/commitizen/) in order to standardize a way of committing rules


pkgId: 322fd5a8ad65e80f568f1288f11074bda3ea2663eb7ba72f5a8ea28079415939
name: python-dataclasses-json
arch: src
version: 0.6.7
epoch: 0
release: 1
summary: Easily serialize dataclasses to and from JSON.
url: https://github.com/lidatong/dataclasses-json
rpm_license: MIT
rpm_group: Unspecified
rpm_buildhost: localhost
location_href: Packages/python-dataclasses-json-0.6.7-1.src.rpm
checksum_type: sha256
description:
  ![](https://github.com/lidatong/dataclasses-json/workflows/dataclasses-json/badge.svg)

  This library provides a simple API for encoding and decoding [dataclasses](https://docs.python.org/3/library/dataclasses.html) to and from JSON.

  It's very easy to get started.

  [README / Documentation website](https://lidatong.github.io/dataclasses-json). Features a navigation bar and search functionality, and should mirror this README exactly -- take a look!



  `pip install dataclasses-json`

  ```python
  from dataclasses import dataclass
  from dataclasses_json import dataclass_json


  @dataclass_json
  @dataclass
  class Person:
      name: str


  person = Person(name='lidatong')
  person.to_json()  # '{"name": "lidatong"}' <- this is a string
  person.to_dict()  # {'name': 'lidatong'} <- this is a dict
  Person.from_json('{"name": "lidatong"}')  # Person(1)
  Person.from_dict({'name': 'lidatong'})  # Person(1)




  Person.from_json('{"name": 42}')  # This is ok. 42 is not a `str`, but
                                    
  Person.schema().loads('{"name": 42}')  # Error! Raises `ValidationError`
  ```

  **What if you want to work with camelCase JSON?**

  ```python

  from dataclasses import dataclass
  from dataclasses_json import dataclass_json, LetterCase

  @dataclass_json(letter_case=LetterCase.CAMEL)  # now all fields are encoded/decoded from camelCase
  @dataclass
  class ConfiguredSimpleExample:
      int_field: int

  ConfiguredSimpleExample(1).to_json()  # {"intField": 1}
  ConfiguredSimpleExample.from_json('{"intField": 1}')  # ConfiguredSimpleExample(1)
  ```



  It's recursive (see caveats below), so you can easily work with nested dataclasses.
  In addition to the supported types in the
  [py to JSON table](https://docs.python.org/3/library/json.html#py-to-json-table), this library supports the following:

  - any arbitrary [Collection](https://docs.python.org/3/library/collections.abc.html#collections.abc.Collection) type is supported.
  [Mapping](https://docs.python.org/3/library/collections.abc.html#collections.abc.Mapping) types are encoded as JSON objects and `str` types as JSON strings.
  Any other Collection types are encoded into JSON arrays, but decoded into the original collection types.

  - [datetime](https://docs.python.org/3/library/datetime.html#available-types)
  objects. `datetime` objects are encoded to `float` (JSON number) using
  [timestamp](https://docs.python.org/3/library/datetime.html#datetime.datetime.timestamp).
  As specified in the `datetime` docs, if your `datetime` object is naive, it will
  assume your system local timezone when calling `.timestamp()`. JSON numbers
  corresponding to a `datetime` field in your dataclass are decoded
  into a datetime-aware object, with `tzinfo` set to your system local timezone.
  Thus, if you encode a datetime-naive object, you will decode into a
  datetime-aware object. This is important, because encoding and decoding won't
  strictly be inverses. See [this section](#Overriding) if you want to override this default
  behavior (for example, if you want to use ISO).

  - [UUID](https://docs.python.org/3/library/uuid.html#uuid.UUID) objects. They
  are encoded as `str` (JSON string).

  - [Decimal](https://docs.python.org/3/library/decimal.html) objects. They are
  also encoded as `str`.

  **The [latest release](https://github.com/lidatong/dataclasses-json/releases/latest) is compatible with both Python 3.7 and Python 3.6 (with the dataclasses backport).**





  ```python
  from dataclasses import dataclass
  from dataclasses_json import dataclass_json

  @dataclass_json
  @dataclass
  class Person:
      name: str

  lidatong = Person('lidatong')


  lidatong.to_json()  # '{"name": "lidatong"}'


  Person.from_json('{"name": "lidatong"}')  # Person(name='lidatong')
  ```

  Note that the `@dataclass_json` decorator must be stacked above the `@dataclass`
  decorator (order matters!)



  ```python
  from dataclasses import dataclass
  from dataclasses_json import DataClassJsonMixin

  @dataclass
  class Person(DataClassJsonMixin):
      name: str

  lidatong = Person('lidatong')


  assert Person.from_json(lidatong.to_json()) == lidatong
  ```

  Pick whichever approach suits your taste. Note that there is better support for
   the mixin approach when using _static analysis_ tools (e.g. linting, typing),
   but the differences in implementation will be invisible in _runtime_ usage.







  ```python
  from dataclasses import dataclass
  from dataclasses_json import dataclass_json

  @dataclass_json
  @dataclass
  class Person:
      name: str
  ```

  **Encode into a JSON array containing instances of my Data Class**

  ```python
  people_json = [Person('lidatong')]
  Person.schema().dumps(people_json, many=True)  # '[{"name": "lidatong"}]'
  ```

  **Decode a JSON array containing instances of my Data Class**

  ```python
  people_json = '[{"name": "lidatong"}]'
  Person.schema().loads(people_json, many=True)  # [Person(name='lidatong')]
  ```

  **Encode as part of a larger JSON object containing my Data Class (e.g. an HTTP
  request/response)**

  ```python
  import json

  response_dict = {
      'response': {
          'person': Person('lidatong').to_dict()
      }
  }

  response_json = json.dumps(response_dict)
  ```

  In this case, we do two steps. First, we encode the dataclass into a
  **python dictionary** rather than a JSON string, using `.to_dict`.

  Second, we leverage the built-in `json.dumps` to serialize our `dataclass` into
  a JSON string.

  **Decode as part of a larger JSON object containing my Data Class (e.g. an HTTP
  response)**

  ```python
  import json

  response_dict = json.loads('{"response": {"person": {"name": "lidatong"}}}')

  person_dict = response_dict['response']

  person = Person.from_dict(person_dict)
  ```

  In a similar vein to encoding above, we leverage the built-in `json` module.

  First, call `json.loads` to read the entire JSON object into a
  dictionary. We then access the key of the value containing the encoded dict of
  our `Person` that we want to decode (`response_dict['response']`).

  Second, we load in the dictionary using `Person.from_dict`.




  This can be by calling `.schema()` and then using the corresponding
  encoder/decoder methods, ie. `.load(...)`/`.dump(...)`.

  **Encode into a single Python dictionary**

  ```python
  person = Person('lidatong')
  person.to_dict()  # {'name': 'lidatong'}
  ```

  **Encode into a list of Python dictionaries**

  ```python
  people = [Person('lidatong')]
  Person.schema().dump(people, many=True)  # [{'name': 'lidatong'}]
  ```

  **Decode a dictionary into a single dataclass instance**

  ```python
  person_dict = {'name': 'lidatong'}
  Person.from_dict(person_dict)  # Person(name='lidatong')
  ```

  **Decode a list of dictionaries into a list of dataclass instances**

  ```python
  people_dicts = [{"name": "lidatong"}]
  Person.schema().load(people_dicts, many=True)  # [Person(name='lidatong')]
  ```



  JSON letter case by convention is camelCase, in Python members are by convention snake_case.

  You can configure it to encode/decode from other casing schemes at both the class level and the field level.

  ```python
  from dataclasses import dataclass, field

  from dataclasses_json import LetterCase, config, dataclass_json



  @dataclass_json(letter_case=LetterCase.CAMEL)
  @dataclass
  class Person:
      given_name: str
      family_name: str

  Person('Alice', 'Liddell').to_json()  # '{"givenName": "Alice"}'
  Person.from_json('{"givenName": "Alice", "familyName": "Liddell"}')  # Person('Alice', 'Liddell')


  @dataclass_json
  @dataclass
  class Person:
      given_name: str = field(metadata=config(letter_case=LetterCase.CAMEL))
      family_name: str

  Person('Alice', 'Liddell').to_json()  # '{"givenName": "Alice"}'

  Person.from_json('{"givenName": "Alice", "family_name": "Liddell"}')  # Person('Alice', 'Liddell')
  ```

  **This library assumes your field follows the Python convention of snake_case naming.**
  If your field is not `snake_case` to begin with and you attempt to parameterize `LetterCase`,
  the behavior of encoding/decoding is undefined (most likely it will result in subtle bugs).



  ```python
  from dataclasses import dataclass, field

  from dataclasses_json import config, dataclass_json

  @dataclass_json
  @dataclass
  class Person:
      given_name: str = field(metadata=config(field_name="overriddenGivenName"))

  Person(given_name="Alice")  # Person('Alice')
  Person.from_json('{"overriddenGivenName": "Alice"}')  # Person('Alice')
  Person('Alice').to_json()  # {"overriddenGivenName": "Alice"}
  ```



  By default, any fields in your dataclass that use `default` or
  `default_factory` will have the values filled with the provided default, if the
  corresponding field is missing from the JSON you're decoding.

  **Decode JSON with missing field**

  ```python
  @dataclass_json
  @dataclass
  class Student:
      id: int
      name: str = 'student'

  Student.from_json('{"id": 1}')  # Student(id=1, name='student')
  ```

  Notice `from_json` filled the field `name` with the specified default 'student'
  when it was missing from the JSON.

  Sometimes you have fields that are typed as `Optional`, but you don't
  necessarily want to assign a default. In that case, you can use the
  `infer_missing` kwarg to make `from_json` infer the missing field value as `None`.

  **Decode optional field without default**

  ```python
  @dataclass_json
  @dataclass
  class Tutor:
      id: int
      student: Optional[Student] = None

  Tutor.from_json('{"id": 1}')  # Tutor(id=1, student=None)
  ```

  Personally I recommend you leverage dataclass defaults rather than using
  `infer_missing`, but if for some reason you need to decouple the behavior of
  JSON decoding from the field's default value, this will allow you to do so.




  By default, it is up to the implementation what happens when a `json_dataclass` receives input parameters that are not defined.
  (the `from_dict` method ignores them, when loading using `schema()` a ValidationError is raised.)
  There are three ways to customize this behavior.

  Assume you want to instantiate a dataclass with the following dictionary:
  ```python
  dump_dict = {"endpoint": "some_api_endpoint", "data": {"foo": 1, "bar": "2"}, "undefined_field_name": [1, 2, 3]}
  ```

  1. You can enforce to always raise an error by setting the `undefined` keyword to `Undefined.RAISE`
   (`'RAISE'` as a case-insensitive string works as well). Of course it works normally if you don't pass any undefined parameters.

  ```python
  from dataclasses_json import Undefined

  @dataclass_json(undefined=Undefined.RAISE)
  @dataclass()
  class ExactAPIDump:
      endpoint: str
      data: Dict[str, Any]

  dump = ExactAPIDump.from_dict(dump_dict)  # raises UndefinedParameterError
  ```

  2. You can simply ignore any undefined parameters by setting the `undefined` keyword to `Undefined.EXCLUDE`
   (`'EXCLUDE'` as a case-insensitive string works as well). Note that you will not be able to retrieve them using `to_dict`:

  ```python
  from dataclasses_json import Undefined

  @dataclass_json(undefined=Undefined.EXCLUDE)
  @dataclass()
  class DontCareAPIDump:
      endpoint: str
      data: Dict[str, Any]

  dump = DontCareAPIDump.from_dict(dump_dict)  # DontCareAPIDump(endpoint='some_api_endpoint', data={'foo': 1, 'bar': '2'})
  dump.to_dict()  # {"endpoint": "some_api_endpoint", "data": {"foo": 1, "bar": "2"}}
  ```

  3. You can save them in a catch-all field and do whatever needs to be done later. Simply set the `undefined`
  keyword to `Undefined.INCLUDE` (`'INCLUDE'` as a case-insensitive string works as well) and define a field
  of type `CatchAll` where all unknown values will end up.
   This simply represents a dictionary that can hold anything.
   If there are no undefined parameters, this will be an empty dictionary.

  ```python
  from dataclasses_json import Undefined, CatchAll

  @dataclass_json(undefined=Undefined.INCLUDE)
  @dataclass()
  class UnknownAPIDump:
      endpoint: str
      data: Dict[str, Any]
      unknown_things: CatchAll

  dump = UnknownAPIDump.from_dict(dump_dict)  # UnknownAPIDump(endpoint='some_api_endpoint', data={'foo': 1, 'bar': '2'}, unknown_things={'undefined_field_name': [1, 2, 3]})
  dump.to_dict()  # {'endpoint': 'some_api_endpoint', 'data': {'foo': 1, 'bar': '2'}, 'undefined_field_name': [1, 2, 3]}
  ```

  Notes:
  - When using `Undefined.INCLUDE`, an `UndefinedParameterError` will be raised if you don't specify
  exactly one field of type `CatchAll`.
  - Note that `LetterCase` does not affect values written into the `CatchAll` field, they will be as they are given.
  - When specifying a default (or a default factory) for the the `CatchAll`-field, e.g. `unknown_things: CatchAll = None`, the default value will be used instead of an empty dict if there are no undefined parameters.
  - Calling __init__ with non-keyword arguments resolves the arguments to the defined fields and writes everything else into the catch-all field.

  4. All 3 options work as well using `schema().loads` and `schema().dumps`, as long as you don't overwrite it by specifying `schema(unknown=<a marshmallow value>)`.
  marshmallow uses the same 3 keywords ['include', 'exclude', 'raise'](https://marshmallow.readthedocs.io/en/stable/quickstart.html#handling-unknown-fields).

  5. All 3 operations work as well using `__init__`, e.g. `UnknownAPIDump(**dump_dict)` will **not** raise a `TypeError`, but write all unknown values to the field tagged as `CatchAll`.
     Classes tagged with `EXCLUDE` will also simply ignore unknown parameters. Note that classes tagged as `RAISE` still raise a `TypeError`, and **not** a `UndefinedParameterError` if supplied with unknown keywords.




  See [Overriding](#Overriding)


  Object hierarchies where fields are of the type that they are declared within require a small
  type hinting trick to declare the forward reference.
  ```python
  from typing import Optional
  from dataclasses import dataclass
  from dataclasses_json import dataclass_json

  @dataclass_json
  @dataclass
  class Tree():
      value: str
      left: Optional['Tree']
      right: Optional['Tree']
  ```

  Avoid using
  ```python
  from __future__ import annotations
  ```
  as it will cause problems with the way dataclasses_json accesses the type annotations.


  Data types specific to libraries commonly used in data analysis and machine learning like [numpy](https://github.com/numpy/numpy) and [pandas](https://github.com/pandas-dev/pandas) are not supported by default, but you can easily enable them by using custom decoders and encoders. Below are two examples for `numpy` and `pandas` types.

  ```python
  from dataclasses import field, dataclass
  from dataclasses_json import config, dataclass_json
  import numpy as np
  import pandas as pd

  @dataclass_json
  @dataclass
  class DataWithNumpy:
      my_int: np.int64 = field(metadata=config(decoder=np.int64))
      my_float: np.float64 = field(metadata=config(decoder=np.float64))
      my_array: np.ndarray = field(metadata=config(decoder=np.asarray))
  DataWithNumpy.from_json("{\"my_int\": 42, \"my_float\": 13.37, \"my_array\": [1,2,3]}")

  @dataclass_json
  @dataclass
  class DataWithPandas:
      my_df: pd.DataFrame = field(metadata=config(decoder=pd.DataFrame.from_records, encoder=lambda x: x.to_dict(orient="records")))
  data = DataWithPandas.from_dict({"my_df": [{"col1": 1, "col2": 2}, {"col1": 3, "col2": 4}]})




  data.to_dict()

  ```



  Using the `dataclass_json` decorator or mixing in `DataClassJsonMixin` will
  provide you with an additional method `.schema()`.

  `.schema()` generates a schema exactly equivalent to manually creating a
  marshmallow schema for your dataclass. You can reference the [marshmallow API docs](https://marshmallow.readthedocs.io/en/3.0/api_reference.html#schema)
  to learn other ways you can use the schema returned by `.schema()`.

  You can pass in the exact same arguments to `.schema()` that you would when
  constructing a `PersonSchema` instance, e.g. `.schema(many=True)`, and they will
  get passed through to the marshmallow schema.


  ```python
  from dataclasses import dataclass
  from dataclasses_json import dataclass_json

  @dataclass_json
  @dataclass
  class Person:
      name: str


  from marshmallow import Schema, fields

  class PersonSchema(Schema):
      name = fields.Str()
  ```

  Briefly, on what's going on under the hood in the above examples: calling
  `.schema()` will have this library generate a
  [marshmallow schema]('https://marshmallow.readthedocs.io/en/3.0/api_reference.html#schema)
  for you. It also fills in the corresponding object hook, so that marshmallow
  will create an instance of your Data Class on `load` (e.g.
  `Person.schema().load` returns a `Person`) rather than a `dict`, which it does
  by default in marshmallow.

  **Performance note**

  `.schema()` is not cached (it generates the schema on every call), so if you
  have a nested Data Class you may want to save the result to a variable to
  avoid re-generation of the schema on every usage.

  ```python
  person_schema = Person.schema()
  person_schema.dump(people, many=True)



  person_schema.dump(person)
  ```





  For example, you might want to encode/decode `datetime` objects using ISO format
  rather than the default `timestamp`.

  ```python
  from dataclasses import dataclass, field
  from dataclasses_json import dataclass_json, config
  from datetime import datetime
  from marshmallow import fields

  @dataclass_json
  @dataclass
  class DataClassWithIsoDatetime:
      created_at: datetime = field(
          metadata=config(
              encoder=datetime.isoformat,
              decoder=datetime.fromisoformat,
              mm_field=fields.DateTime(format='iso')
          )
      )
  ```



  Similarly, you might want to extend `dataclasses_json` to encode `date` objects.

  ```python
  from dataclasses import dataclass, field
  from dataclasses_json import dataclass_json, config
  from datetime import date
  from marshmallow import fields

  dataclasses_json.cfg.global_config.encoders[date] = date.isoformat
  dataclasses_json.cfg.global_config.decoders[date] = date.fromisoformat

  @dataclass_json
  @dataclass
  class DataClassWithIsoDatetime:
      created_at: date
      modified_at: date
      accessed_at: date
  ```

  As you can see, you can **override** or **extend** the default codecs by providing a "hook" via a
  callable:
  - `encoder`: a callable, which will be invoked to convert the field value when encoding to JSON
  - `decoder`: a callable, which will be invoked to convert the JSON value when decoding from JSON
  - `mm_field`: a marshmallow field, which will affect the behavior of any operations involving `.schema()`

  Note that these hooks will be invoked regardless if you're using
  `.to_json`/`dump`/`dumps`
  and `.from_json`/`load`/`loads`. So apply overrides / extensions judiciously, making sure to
  carefully consider whether the interaction of the encode/decode/mm_field is consistent with what you expect!




  All the `dataclasses_json.config` does is return a mapping, namespaced under the key `'dataclasses_json'`.

  Say there's another module, `other_dataclass_package` that uses metadata. Here's how you solve your problem:

  ```python
  metadata = {'other_dataclass_package': 'some metadata...'}  # pre-existing metadata for another dataclass package
  dataclass_json_config = config(
              encoder=datetime.isoformat,
              decoder=datetime.fromisoformat,
              mm_field=fields.DateTime(format='iso')
          )
  metadata.update(dataclass_json_config)

  @dataclass_json
  @dataclass
  class DataClassWithIsoDatetime:
      created_at: datetime = field(metadata=metadata)
  ```

  You can also manually specify the dataclass_json configuration mapping.

  ```python
  @dataclass_json
  @dataclass
  class DataClassWithIsoDatetime:
      created_at: date = field(
          metadata={'dataclasses_json': {
              'encoder': date.isoformat,
              'decoder': date.fromisoformat,
              'mm_field': fields.DateTime(format='iso')
          }}
      )
  ```



  ```python
  from dataclasses import dataclass
  from dataclasses_json import dataclass_json

  from typing import List

  @dataclass_json
  @dataclass(frozen=True)
  class Minion:
      name: str


  @dataclass_json
  @dataclass(frozen=True)
  class Boss:
      minions: List[Minion]

  boss = Boss([Minion('evil minion'), Minion('very evil minion')])
  boss_json = """
  {
      "minions": [
          {
              "name": "evil minion"
          },
          {
              "name": "very evil minion"
          }
      ]
  }
  """.strip()

  assert boss.to_json(indent=4) == boss_json
  assert Boss.from_json(boss_json) == boss
  ```



  Take a look at [this issue](https://github.com/lidatong/dataclasses-json/issues/228)



  Note this library is still pre-1.0.0 (SEMVER).

  The current convention is:
  - **PATCH** version upgrades for bug fixes and minor feature additions.
  - **MINOR** version upgrades for big API features and breaking changes.

  Once this library is 1.0.0, it will follow standard SEMVER conventions.



  Any version that is not listed in the table below we do not test against, though you might still be able to install the library. For future Python versions, please open an issue and/or a pull request, adding them to the CI suite.


  | Python version range | Compatible dataclasses-json version |
  |----------------------|:-----------------------------------:|
  | 3.7.x - 3.12.x       |            0.5.x - 0.6.x            |
  | >= 3.13.x            |         No official support (yet)   |




  Currently the focus is on investigating and fixing bugs in this library, working
  on performance, and finishing [this issue](https://github.com/lidatong/dataclasses-json/issues/31).

  That said, if you think there's a feature missing / something new needed in the
  library, please see the contributing section below.




  First of all, thank you for being interested in contributing to this library.
  I really appreciate you taking the time to work on this project.

  - If you're just interested in getting into the code, a good place to start are
  issues tagged as bugs.
  - If introducing a new feature, especially one that modifies the public API,
  consider submitting an issue for discussion before a PR. Please also take a look
  at existing issues / PRs to see what you're proposing has  already been covered
  before / exists.
  - I like to follow the commit conventions documented [here](https://www.conventionalcommits.org/en/v1.0.0/#summary)



  This project uses [Poetry](https://python-poetry.org/) for dependency and venv management. It is quite simple to get ready for your first commit:
  - [Install](https://python-poetry.org/docs/#installation) latest stable Poetry
  - Navigate to where you cloned `dataclasses-json`
  - Run `poetry install`
  - Create a branch and start writing code!


pkgId: ebad0b6c0e29272496e9eec1b4cf186eceab2e8485a18caeb42d9e8d44335759
name: python-dataclasses-jsonschema
arch: src
version: 2.16.0
epoch: 0
release: 1
summary: JSON schema generation from dataclasses
url: https://github.com/s-knibbs/dataclasses-jsonschema
rpm_license: MIT
rpm_group: Unspecified
rpm_buildhost: localhost
location_href: Packages/python-dataclasses-jsonschema-2.16.0-1.src.rpm
checksum_type: sha256
description:
  **Please Note:** This project is in maintenance mode. I'm currently only making urgent bugfixes.
  A library to generate JSON Schema from python 3.7 dataclasses. Python 3.6 is supported through the `dataclasses backport <https://github.com/ericvsmith/dataclasses>`_. Aims to be a more lightweight alternative to similar projects such as `marshmallow <https://github.com/marshmallow-code/marshmallow>`_ & `pydantic <https://github.com/samuelcolvin/pydantic>`_.


pkgId: 713fdbb1a2dfc074230a7424290b7e6188b3a989f594939f4c897c78c4ccdffe
name: python-dataclasses-struct
arch: src
version: 0.8.3
epoch: 0
release: 1
summary: Converting dataclasses to and from fixed-length binary data using struct
url: https://github.com/harrymander/dataclasses-struct
rpm_license: MIT
rpm_group: Unspecified
rpm_buildhost: localhost
location_href: Packages/python-dataclasses-struct-0.8.3-1.src.rpm
checksum_type: sha256
description:
  [![PyPI version](https://img.shields.io/pypi/v/dataclasses-struct)](https://pypi.org/project/dataclasses-struct/)
  [![Python versions](https://img.shields.io/pypi/pyversions/dataclasses-struct)](https://pypi.org/project/dataclasses-struct/)
  [![Tests status](https://github.com/harrymander/dataclasses-struct/actions/workflows/test.yml/badge.svg?event=push)]()
  [![Code coverage](https://img.shields.io/codecov/c/gh/harrymander/dataclasses-struct)](https://app.codecov.io/gh/harrymander/dataclasses-struct)
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/harrymander/dataclasses-struct/blob/main/LICENSE)

  A simple Python package that combines
  [`dataclasses`](https://docs.python.org/3/library/dataclasses.html) with
  [`struct`](https://docs.python.org/3/library/struct.html) for packing and
  unpacking Python dataclasses to fixed-length `bytes` representations.

  ```python
  from typing import Annotated  # use typing_extensions on Python <3.9
  import dataclasses_struct as dcs

  @dcs.dataclass()
  class Test:
      x: int  # or dcs.I64, i.e., a signed 64-bit integer
      y: float  # or dcs.F64, i.e., a double-precision (64-bit) floating point
      z: dcs.U8  # unsigned 8-bit integer
      s: Annotated[bytes, 10]  # fixed-length byte array of length 10

  @dcs.dataclass()
  class Container:
      test1: Test
      test2: Test
  ```

  ```python
  >>> dcs.is_dataclass_struct(Test)
  True
  >>> t1 = Test(100, -0.25, 0xff, b'12345')
  >>> dcs.is_dataclass_struct(t1)
  True
  >>> t1
  Test(x=100, y=-0.25, z=255, s=b'12345')
  >>> packed = t1.pack()
  >>> packed
  b'd\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xd0\xbf\xff12345\x00\x00\x00\x00\x00'
  >>> Test.from_packed(packed)
  Test(x=100, y=-0.25, z=255, s=b'12345\x00\x00\x00\x00\x00')
  >>> t2 = Test(1, 100, 12, b'hello, world')
  >>> c = Container(t1, t2)
  >>> Container.from_packed(c.pack())
  Container(test1=Test(x=100, y=-0.25, z=255, s=b'12345\x00\x00\x00\x00\x00'), test2=Test(x=1, y=100.0, z=12, s=b'hello, wor'))
  ```



  This package is available on pypi:

  ```
  pip install dataclasses-struct
  ```

  To work correctly with [`mypy`](https://www.mypy-lang.org/), an extension is
  required; add to your `mypy.ini`:

  ```ini
  [mypy]
  plugins = dataclasses_struct.ext.mypy_plugin
  ```



  ```python
  from typing import Annotated  # use typing_extensions on Python <3.9
  import dataclasses_struct as dcs

  endians = (
      dcs.NATIVE_ENDIAN_ALIGNED,  # uses system endianness and alignment
      dcs.NATIVE_ENDIAN,  # system endianness, packed representation
      dcs.LITTLE_ENDIAN,
      dcs.BIG_ENDIAN,
      dcs.NETWORK_ENDIAN,
  )

  @dcs.dataclass(endians[0])  # if no endian provided, defaults to NATIVE_ENDIAN_ALIGNED
  class Test:

      
      single_char: dcs.Char
      single_char_alias: bytes  # alias for Char

      
      bool_1: dcs.Bool
      bool_2: bool  # alias for Bool

      
      int8: dcs.I8
      uint8: dcs.U8
      int16: dcs.I16
      uint16: dcs.U16
      int32: dcs.I32
      uint32: dcs.U32
      uint64: dcs.U64
      int64: dcs.I64
      int64_alias: int  # alias for I64

      
      unsigned_size: dcs.Size
      signed_size: dcs.SSize
      pointer: dcs.Pointer

      
      single_precision: dcs.F32  # equivalent to float in C
      double_precision: dcs.F64  # equivalent to double in C
      double_precision_alias: float  # alias for F64

      
      array: Annotated[bytes, 100]  # an array of length 100

      
      
      pad_before: Annotated[int, dcs.PadBefore(4)]
      pad_after: Annotated[int, dcs.PadAfter(2)]
      pad_before_and_after: Annotated[int, dcs.PadBefore(3), dcs.PadAfter(2)]


  @dcs.dataclass(endians[0])  # endianness of contained classes must match
  class Container:
      contained1: Test

      
      contained2: Annotated[Test, dcs.PadBefore(10)]
  ```

  Decorated classes are transformed to a standard Python
  [dataclass](https://docs.python.org/3/library/dataclasses.html) with boilerplate
  `__init__`, `__repr__`, `__eq__` etc. auto-generated. Additionally, two methods
  are added to the class: `pack`, a method for packing an instance of the class to
  `bytes`, and `from_packed`, a class method that returns a new instance of the
  class from its packed `bytes` representation.

  A class or object can be check to see if it is a dataclass-struct using the
  `is_dataclass_struct` function. The `get_struct_size` function will return
  the size in bytes of the packed representation of a dataclass_struct class
  or an instance of one.

  An additional class attribute, `__dataclass_struct__`. The [`struct` format
  string](https://docs.python.org/3/library/struct.html#format-strings), packed
  size, and endianness can be accessed like so:

  ```python
  >>> Test.__dataclass_struct__.format
  '@cc??bBhHiIQqqNnPfdd100s4xqq2x3xq2x'
  >>> Test.__dataclass_struct__.size
  234
  >>> Test.__dataclass_struct__.endianness
  '@'
  ```

  Default attribute values will be validated against their expected type and
  allowable value range. For example,

  ```python3
  import dataclasses_struct as dcs

  @dcs.dataclass()
  class Test:
      x: dcs.U8 = -1
  ```

  will raise a `ValueError`. This can be disabled by passing `validate=False` to
  the `dataclasses_struct.dataclass` decorator.



  Pull requests are welcomed!

  This project uses [Poetry](https://python-poetry.org/) as its build system. To
  install all dependencies (including development dependencies) into a virtualenv
  for local development:

  ```
  poetry install --with dev
  ```

  Uses `pytest` for testing:

  ```
  poetry run pytest
  ```

  (Omit the `poetry run` if the Poetry virtualenv is activated.)

  Uses `ruff` and `flake8` for linting, which is enforced on pull requests:

  ```
  poetry run ruff check .
  poetry run flake8
  ```

  See `pyproject.toml` for the list of enabled checks. I recommend installing the
  provided [`pre-commmit`](https://pre-commit.com/) hooks to ensure new commits
  pass linting:

  ```
  pre-commit install
  ```

  This will help speed-up pull requests by reducing the chance of failing CI
  checks.

  PRs must also pass `mypy` checks (`poetry run mypy`).


