Ycecream

Latest version: v1.3.20.post0

Safety actively analyzes 687881 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 5 of 7

1.1.9

=========================
New functionality (0)
---------------------
Added the values_only attribute. If False (the default), both the left-hand side (if possible) and the
value will be printed. If True, the left_hand side will be suppressed:
|hello = "world"
|y(hello, 2 * hello)
|y(hello, 2 * hello, values_only=True)
prints
|y| hello: 'world', 2 * hello = 'worldworld'
|y| 'world', 'worldworld'
The values_only=True version of y can be seen as a supercharged print/pprint.

New functionality (1)
---------------------
When ycecream is disabled, either via y.configure(enbabled=False) or ycecream.enable(False),
ycecream still has to check for usage as a decorator or context manager, which can be rather time
consuming.
In order to speed up a program with disabled ycecream calls, it is now possible to specify
y.configure(enabled=[]) or ycecream.enabled([]), in which case y will always just return
the given arguments. If ycecream is disabled this way, usage as a y() decorator or as a with y():
context manager will raise a runtime error, though. The y decorator without parentheses will
not raise any exception, though.
Note that calls with as_str=True will not be affected at all by the enabled flag.

The table below shows it all.
---------------------------------------------------------------------
enabled=True enabled=False enabled=[]
---------------------------------------------------------------------
execution speed normal normal fast
y() as specified no output no output
y() as specified no output TypeError
y as specified no output no output
with y(): as specified no output AttributeError
y(as_str=True) as specified as specified as specified
---------------------------------------------------------------------


Bug fix (0)
-----------
A file ycecream.json could not be found in the site_packages installation. Fixed.
Added tests to check proper ycecream.json search functionality.

1.1.8

=========================
Added functionality (0)
-----------------------
Ycecream now supports REPLs, be it with limited functionality:
- all arguments are just presented as such, i.e. no left-hand side, e.g.
>>> hello = "world"
>>> y(hello, hello * 2)
y| 'hello', 'hellohello'
('hello', 'hellohello')
- line numbers are never shown
- use as a decorator is not supported
- use as a context manager is not supported

Bug fix (0)
-----------
Since version 1.1.6, delta was not calculated properly. Fixed.
Added a test to detect this type of bug.

1.1.7

=========================
Added functionality (0)
-----------------------
'wrap_indent' can now be
- a string
- an integer, in which case the indent will be that amount of blanks

Added check for REPL (0)
------------------------
Ycecream now checks explicitely whether it is run from a REPL. If so, a NotImplementedError is raised
immediately at import time.

Bug fix (0)
-----------
Some arguments to y could cause an exception other than ValueError. Fixed.

1.1.6

=========================
New functionality (0)
---------------------
It is now possible to use the compact option of pprint.pformat:

|a = 9 * ['0123456789']
|y(a)
|y(a, compact=True)

prints
|y|
| a:
| ['0123456789',
| '0123456789',
| '0123456789',
| '0123456789',
| '0123456789',
| '0123456789',
| '0123456789',
| '0123456789',
| '0123456789']
|y|
| a:
| ['0123456789', '0123456789', '0123456789', '0123456789', '0123456789',
| '0123456789', '0123456789', '0123456789', '0123456789']

New functionality (1)
---------------------
Also made availabe the indent and depth parameters of pprint.format, so we can now say
|s="=============================================="
|a=[40 * "1",[40 * "2",[40 * "3",[40 * "4",[40*'5']]]],40 * "1"]
|y(a, depth=3,indent=4)
to get
|y|
| a:
| [ '1111111111111111111111111111111111111111',
| [ '2222222222222222222222222222222222222222',
| ['3333333333333333333333333333333333333333', [...]]],
| '1111111111111111111111111111111111111111']

API change (0)
--------------
The 'show_context' attribute has been changed to 'show_line_number'.

Change of functionality (0)
---------------------------
The NoSourceCodeAvailable exception has been changed to NotImplementedError with a clear message.

Changed output (0)
------------------
The line number is now prefixed by a , whereas the filename is now suppressed if this concerns the current
program. If it is in another file, the filename will follow the line number, like 12[foo.py]

Bug fix (0)
-----------
It is now possible to have keyword arguments in functions/methods decorated with y.

Tests (0)
---------
Added many tests, including testing for line numbers.

Documentation update (0)
------------------------
The readme file now clearly mentions that the y is discouraged as it can't reliably detect the source
when decorating a function definition of more than one line. Instead use y() that works always as expected.

Internal change (0)
-------------------
Made the code much more linear, thus avoiding many calls and a clearer structure (IMHO).

Complete overhaul of line numbers and source code. Now all code is cached in a codes dict (per file)

Y.__call__() now always works on a new Y instance that is used in the actual processing, thus making
the code shorter and more stable

Mass assignment of attributes now via assign function, thus improving stability and shortening code.

1.1.5

=========================
Now, the line_length is properly observed and indentation is not anymore dependent on prefix.
Instead by default 4 blanks (this can overriden with the wrap_indent attribute) are used as an indent.

The attributes context_delimiter and pair_delimiter are now documented.

Exception NoSourceAvailableError is now correctly raised.

Internal change: complete overhaul of formatting.

1.1.4

=========================
Increased the resolution of show_date and show_time (now microseconds).
Delta now start on creation of an Y object and is thus different for each instance.

It is now possible to query the current delta with Y.delta and to reset it with Y.delta = 0

y() can now also be used as a context manager, primarily to time sections of code rather than a function or method:
| with y():
| time.sleep(1)
will print
| y| enter
| y| exit in 1.000822 seconds

If you also want to see where the context manager was defined:

| with y(show_context=True):
| time.sleep(1)
will print something like:
| y| x6.py:19 ==> enter
| y| x6.py:19 ==> exit in 1.000544 seconds

As with the decorator y, the show_enter and show_exit parameters may be used to show/hide that information.

The ouput attribute can now also be the string
"logging.debug", "logging.info", "logging.warning", "logging.error" or "logging.critical"
, which is primarily useful when a configuration is read from ycecream.json .
Note that
y.configure(logging.info)
ie essentially the same as
y.configure("logging.info")

Internal change: now uses time.perf_counter() to improve accuracy of timings

Page 5 of 7

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.