Skip to main content

Orange

Python code formatter

PyPi version

What it is

Orange is fork of Black maintained by Quantlane.

Installation

pip install ql-orange

The Orange code style

Orange mainly follows code style used by Black with few key differences:

  • indentation with tabs,
  • single-quoted strings,
  • default line length is 110,

and some extra rules.

Spaces around keyword arguments

# Black
def func(x, y=None):
    pass


func(1, y=2)
# Orange
def func(x, y = None):
	pass


func(1, y = 2)

Multi-line comprehensions

Orange explodes comprehensions if they don't fit on one line.

# Black
long_list_of_comprehension = [
    pineapple for pineapple in self.pineapples if getattr(pineapple, "is_still_fresh", False)
]
short = [s for s in l if s]
# Orange
long_list_of_comprehension = [
	pineapple
	for pineapple in self.pineapples
	if getattr(pineapple, 'is_still_fresh', False)
]
short = [s for s in l if s]

Extended magic trailing comma

Black uses magic trailing comma to keep formatting of collections multi-line even if they would fit into one line. Orange extends magic trailing comma to work on:

  • function definitions,
  • function calls, and
  • nested collections
# Black
def f(a: int, b: str, c: Optional[float] = None,) -> None:
    pass


f(
    1, "a", None,
)
data = {
    "time": datetime.datetime.now(),
    "id": str(data.id),
    "key": some_value,
    "labels": ["Label1", "Label that is quite long",],
}
# Orange
def f(
	a: int,
	b: str,
	c: Optional[float] = None,
) -> None:
	pass


f(
	1,
	'a',
	None,
)
data = {
	'time': datatime.datetime.now(),
	'id': str(data.id),
	'key': some_value,
	'labels': [
		'Label1',
		'Label that is quite long',
	],
}

Usage

orange {source_file_or_directory}

Command line options

Orange provides the same options as black. You can list them by running orange --help:

orange [OPTIONS] [SRC]...

Options:
  -c, --code TEXT                 Format the code passed in as a string.
  -l, --line-length INTEGER       How many characters per line to allow.
                                  [default: 110]
  -t, --target-version [py27|py33|py34|py35|py36|py37|py38]
                                  Python versions that should be supported by
                                  Black's output. [default: per-file auto-
                                  detection]
  --py36                          Allow using Python 3.6-only syntax on all
                                  input files.  This will put trailing commas
                                  in function signatures and calls also after
                                  *args and **kwargs. Deprecated; use
                                  --target-version instead. [default: per-file
                                  auto-detection]
  --pyi                           Format all input files like typing stubs
                                  regardless of file extension (useful when
                                  piping source on standard input).
  -S, --skip-string-normalization
                                  Don't normalize string quotes or prefixes.
  --check                         Don't write the files back, just return the
                                  status.  Return code 0 means nothing would
                                  change.  Return code 1 means some files
                                  would be reformatted.  Return code 123 means
                                  there was an internal error.
  --diff                          Don't write the files back, just output a
                                  diff for each file on stdout.
  --fast / --safe                 If --fast given, skip temporary sanity
                                  checks. [default: --safe]
  --include TEXT                  A regular expression that matches files and
                                  directories that should be included on
                                  recursive searches.  An empty value means
                                  all files are included regardless of the
                                  name.  Use forward slashes for directories
                                  on all platforms (Windows, too).  Exclusions
                                  are calculated first, inclusions later.
                                  [default: \.pyi?$]
  --exclude TEXT                  A regular expression that matches files and
                                  directories that should be excluded on
                                  recursive searches.  An empty value means no
                                  paths are excluded. Use forward slashes for
                                  directories on all platforms (Windows, too).
                                  Exclusions are calculated first, inclusions
                                  later.  [default: /(\.eggs|\.git|\.hg|\.mypy
                                  _cache|\.nox|\.tox|\.venv|_build|buck-
                                  out|build|dist)/]
  -q, --quiet                     Don't emit non-error messages to stderr.
                                  Errors are still emitted, silence those with
                                  2>/dev/null.
  -v, --verbose                   Also emit messages to stderr about files
                                  that were not changed or were ignored due to
                                  --exclude=.
  --version                       Show the version and exit.
  --config PATH                   Read configuration from PATH.
  -h, --help                      Show this message and exit.

Metadata

Release files for ql-orange 1.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ql-orange 1.4.0
File Size Uploaded
ql-orange-1.4.0.tar.gz 125.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ql-orange 1.4.0
File Interpreter ABI Platform
ql_orange-1.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 264.8 kB

Release files / ql-orange-1.4.0.tar.gz

Download URL ql-orange-1.4.0.tar.gz
Size 125.9 kB
Tags Source
SHA-256 checksum
How to use checksums
5a53bd93dd6ae07225d97ddfb441875e28ad17eda5e57fa154a17bbc9eb71cc9
BLAKE2b-256 checksum
How to use checksums
07d7ec25ab0e8191ab3304d54ee0577b89b05a1fba52f995f3f293ce3271d941
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.15.0 pkginfo/1.8.2 requests/2.27.1 setuptools/58.1.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.8

Release files / ql_orange-1.4.0-py3-none-any.whl

Download URL ql_orange-1.4.0-py3-none-any.whl
Size 138.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6ed2ffdd59f01e23faa1f5c7f780ad4cf1722af4cbac6d3b6c67c1a281e16b21
BLAKE2b-256 checksum
How to use checksums
0bcece57b82aa71c1ede60e795c6db58c0ef029aa9f4cd2a60c08e8015f3dc5e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.15.0 pkginfo/1.8.2 requests/2.27.1 setuptools/58.1.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.8

Release history Release notifications | RSS feed

This release

1.4.0 This release

2 release files

1.3.0

2 release files

1.1.0

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page