Metadata-Version: 2.1
Name: darlog-py23
Version: 1.2.1
Summary: A tiny compatibility module for cross-Python2/3 code.
Home-page: https://github.com/Lex-DRL/darlog-py23
Author: Lex Darlog (Lex-DRL)
Maintainer: Lex Darlog (Lex-DRL)
License: LGPL-3.0-only
Keywords: 2to3,3to2,six,compatibility,wrapper
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: !=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,<4,>=2.7
Description-Content-Type: text/markdown
License-File: LICENSE.md

# [darlog-py23](https://github.com/Lex-DRL/darlog-py23)

A tiny compatibility module for cross-Python2/3 code.
It's not a replacement for neither ``six`` nor ``__future__`` modules but is more of an extension to them.

Defines the very basic stuff:

## Python version booleans
`PY2`, `PY3`, `PY310` - simple flags indicating whether you're running under Python 2, 3 or 3.10+.

## Strings
### `str_types`
A tuple containing all the string types - ready to be passed to `isinstance()`:

* Python 2 - `(str, unicode)`
* Python 3 - `(str, )`

### `unicode`
Type alias:

* Python 2 - `unicode`
* Python 3 - `str`

### `to_least_str()`
Converts the given value to a string:

* Python 2: tries to turn to a `str`, `unicode` if fails.
* Python 3: just an alias for `str()`.

### `str_format()`
Formats a string and doesn't throw an error if any of the given arguments is unicode under Python 2. The resulting string is simply turned to unicode, too.

## DataClasses
### `@attrs` decorator
Tries to use `attr.s` and if it's not found, falls back to built-in decorator from Py3.10 and, finally to 3.7 implementation if available.

If none of those is found, applies the included dataclass implementation, the simplest possible one (`@dataclass_fallback`, see below) - as the last resort, just to avoid exceptions.

### `@dataclass` decorator
Similar to `@attrs`, but tries built-in `@dataclass` first.

I'd recommend using `@attrs` anyway, but here it is.

Tries to use the built-in decorator from Py3.10, falls back to 3.7 implementation, then to `attr.s`. And, finally, to the included `@dataclass_fallback`.

### `@dataclass_fallback` decorator
The minimal implementation of `dataclass` working in any Python version above 2.7. Implements only `init`, `repr` and `eq` features.

It doesn't do any "attribute is `Field` instance" stuff or any other `getattr`/`setattr` magic.

This is what both `@dataclass` and `@attrs` fall back to as the last resort. I don't know why would you need it explicitly, though - but here it is.
