Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ doc/_build/
src/pyq/version.py
html/

.venv*/
venv*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doesn't belong here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you rather a separate PR just for this change? The .gitignore should exclude Python virtual environments in some capacity.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe venvs belong in code repository. For example, I keep my venvs in the .virtualenvs directory. Adding all possible locations will grow .gitignore dramatically and this is not necessary.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per-project virtual environments are a widespread practice. You'll find most large Python projects have a few lines in their .gitignore to exclude them. Besides, we don't need to add "all possible locations" - no need to let perfect be the enemy of good. This addition takes care of all of the most common ones in just two lines.


*.pyc
.coverage
.coverage.*
Expand Down
24 changes: 24 additions & 0 deletions src/pyq/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1052,3 +1052,27 @@ def _trp_call(*args, **kwds):
_set_excepthook(sys.excepthook)
K._k = classmethod(_trp_k)
K.__call__ = _trp_call


# HACK: Fixes https://github.com/KxSystems/pyq/issues/133
try:
import pandas
except ImportError:
pass
else:
# Pandas thinks all non-atom K objects are dicts. This function performs
# the same dict-checking logic used by Pandas, but with a special case for
# K objects.
def _is_dict_like_override(x):
# The import is necessary for K to be in scope because the __code__
# of this function is used elsewhere, with different globals and locals
from pyq import K
if isinstance(x, K):
return x.type() == 99
dict_like_attrs = ("__getitem__", "keys", "__contains__")
return all(hasattr(x, attr) for attr in dict_like_attrs) and not \
isinstance(x, type)

# XXX
pandas.core.dtypes.inference.is_dict_like.__code__ = \
_is_dict_like_override.__code__