Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

argv parsing in 5.x to pass a set, how to

未关闭
#640 2 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
20/100
Issue 类型
缺陷
描述清晰度
需要澄清
活跃度
停滞
技术栈
python
领域
cli

调研方向

首先重现所示的 Voila 命令,并检查 argparse 对 TagRemovePreprocessor.remove_cell_tags 的处理。确定在 5.x 的行为中,集合值选项是如何解析的,然后验证当命令接受该选项且不引发 TraitError 时能够成功完成;issue 未提及任何仓库文件或测试。

由索引模型根据 Issue 内容生成。

描述

After upgrading to 5.x I can no longer use the command I once was with voila - after having read through other issues and the docs I see the parsing has changed.
https://github.com/voila-dashboards/voila/issues/813

The difficulty I am running into - is I don't see how to pass a set as an option?

For example, I used to use:

voila --no-browser --ExecutePreprocessor.timeout=300 --theme=dark --TagRemovePreprocessor.remove_cell_tags='{"hide"}'

but I get the below error when opening notebooks with voila:

Jan 21 16:56:38 abc-123-086427 voila[2580]:   File "/home/ubuntu/miniconda3/envs/data_analysis_lab/lib/python3.8/site-packages/traitlets/traitlets.py", line 610, in _validate
Jan 21 16:56:38 abc-123-086427 voila[2580]:     value = self.validate(obj, value)
Jan 21 16:56:38 abc-123-086427 voila[2580]:   File "/home/ubuntu/miniconda3/envs/data_analysis_lab/lib/python3.8/site-packages/traitlets/traitlets.py", line 2496, in validate
Jan 21 16:56:38 abc-123-086427 voila[2580]:     value = super(Container, self).validate(obj, value)
Jan 21 16:56:38 abc-123-086427 voila[2580]:   File "/home/ubuntu/miniconda3/envs/data_analysis_lab/lib/python3.8/site-packages/traitlets/traitlets.py", line 1845, in validate
Jan 21 16:56:38 abc-123-086427 voila[2580]:     self.error(obj, value)
Jan 21 16:56:38 abc-123-086427 voila[2580]:   File "/home/ubuntu/miniconda3/envs/data_analysis_lab/lib/python3.8/site-packages/traitlets/traitlets.py", line 690, in error
Jan 21 16:56:38 abc-123-086427 voila[2580]:     raise TraitError(e)
Jan 21 16:56:38 abc-123-086427 voila[2580]: traitlets.traitlets.TraitError: The 'remove_cell_tags' trait of a TagRemovePreprocessor instance expected a set, not the str '{"hide"}'.
Jan 21 16:56:38 abc-123-086427 voila[2580]: ERROR:tornado.access:500 GET /voila/render/beta/BSR/Computational_Thinking/what_is_an_algorithm.ipynb (::1) 204.10ms

So for --TagRemovePreprocessor.remove_cell_tags the error is now saying it is expecting a set and not a str

I have tried many combinations such as:

voila --no-browser --ExecutePreprocessor.timeout=300 --theme=dark --TagRemovePreprocessor.remove_cell_tags=hide

Searching through cli options in argparse I don't see a way to pass a set from the cli that TagRemovePreprocessor.remove_cell_tags is expecting.

主要语言
Python
星标
653
派生
217
平均合并
2 天 21 小时
30 天内合并 PR
2

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

ipython/traitlets 的其他 Issue

查看 ipython/traitlets 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。