Merge pull request #1572 from laerus/reprlazy

repr/str for lazyobject
This commit is contained in:
Gil Forsyth 2016-08-17 10:08:03 -04:00 committed by GitHub
commit 51fcf4be85
3 changed files with 22 additions and 2 deletions

15
news/lazyobject-repr.rst Normal file
View file

@ -0,0 +1,15 @@
**Added:**
* ``__repr__`` and ``__str__`` magic method on LazyObject
**Changed:** None
**Deprecated:** None
**Removed:**
* Unused imports in proc, flake8.
**Fixed:** None
**Security:** None

View file

@ -116,6 +116,12 @@ class LazyObject(object):
obj = self._lazy_obj()
return obj | other
def __str__(self):
return str(self._lazy_obj())
def __repr__(self):
return repr(self._lazy_obj())
def lazyobject(f):
"""Decorator for constructing lazy objects from a function."""

View file

@ -15,7 +15,6 @@ import signal
import builtins
import functools
import threading
import importlib
import subprocess
import collections
import collections.abc as abc
@ -24,7 +23,7 @@ from xonsh.platform import ON_WINDOWS, ON_LINUX, ON_POSIX
from xonsh.tools import (redirect_stdout, redirect_stderr, fallback,
print_exception, XonshCalledProcessError)
from xonsh.teepty import TeePTY
from xonsh.lazyasd import LazyObject, lazyobject
from xonsh.lazyasd import lazyobject
# force some lazy imports so we don't have errors on non-windows platforms