environment
Runtime environment detection utilities.
This module provides functions to detect the current execution environment, including testing frameworks, terminals, IDEs, notebook environments, and CI systems. It also includes helpers for IPython/Jupyter display handling.
can_update_ipython_display()
Check if IPython HTML display utilities are available.
This indicates we can safely construct IPython.display.HTML
and update a display handle.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if IPython HTML display is available. |
Source code in src/easyutilities/environment.py
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | |
can_use_ipython_display(handle)
Check if a given IPython DisplayHandle can be updated.
Combines type checking of the handle with availability of IPython HTML utilities.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
handle
|
object
|
The display handle object to check. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the handle can be updated, False otherwise. |
Source code in src/easyutilities/environment.py
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | |
in_colab()
Determine if the current environment is Google Colab.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if running in Google Colab, False otherwise. |
Source code in src/easyutilities/environment.py
59 60 61 62 63 64 65 66 67 68 | |
in_github_ci()
Determine if the current environment is GitHub Actions CI.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if |
Source code in src/easyutilities/environment.py
117 118 119 120 121 122 123 | |
in_jupyter()
Determine if the current environment is a Jupyter Notebook.
Uses multiple detection strategies including IPython availability, config-based detection, and shell class name inspection.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if in Jupyter Notebook, False otherwise. |
Source code in src/easyutilities/environment.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | |
in_pycharm()
Determine if the current environment is PyCharm.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if running inside PyCharm, False otherwise. |
Source code in src/easyutilities/environment.py
45 46 47 48 49 50 51 | |
in_pytest()
Determine if the current environment is running under pytest.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if pytest is loaded in sys.modules, False otherwise. |
Source code in src/easyutilities/environment.py
22 23 24 25 26 27 28 | |
in_warp()
Determine if the current environment is Warp terminal.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if running inside Warp terminal, False otherwise. |
Source code in src/easyutilities/environment.py
36 37 38 39 40 41 42 | |
is_ipython_display_handle(obj)
Check if an object is an IPython DisplayHandle instance.
Tries to import IPython.display.DisplayHandle and uses
isinstance when available. Falls back to a conservative
module name heuristic if IPython is missing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
object
|
The object to check. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if |
Source code in src/easyutilities/environment.py
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | |