0.5.0 a couple issues on first attempt to use
还没有人认领这个 Issue。
评估
调研方向
首先使用 esl_async.py 和 esl_sync.py 重现 Windows 转换,然后检查 unasync Rule 示例所使用的标记化和输出路径。检查换行符、typing_extensions 导入以及制表符缩进的处理;当转换后的文件在 Windows 和较旧的 Python 版本上均有效,并支持从同一目录进行简单调用时,即视为完成。
由索引模型根据 Issue 内容生成。
描述
-
trying to use this on Windows is producing bad EOL in output file. This is because the file is opened binary on read and pulls in '\r\n' but then the file is opened as text on output so ends up writing '\r\r\n' to the output file
-
need to support older versions of python but the following code:
from typing_extensions import AsyncIterator
gets transformed to the invalid:
from typing_extensions import Iterator -
unasync output files are invalid if they use tabbed indentation. Source tabs are getting replaced with a single space on some but not all lines. Actual error trying to run a converted file:
File "C:\cvs\gravitas_v1\incpy\esl_sync.py", line 48
if value is None:
^
IndentationError: unindent does not match any outer indentation level
- a simple way to run this by hand (setup.py is overkill for my needs) to convert a file to another file in the same directory. In my case I want to convert 'esl_async.py' to 'esl_sync.py' in the same folder. This is what I did in order to get this far:
# stdlib imports:
import os
from pathlib import Path
import sys
# 3rd-party imports:
import unasync # pip install unasync
from unasync import std_tokenize, _tokenize, _makedirs_existok
def _untokenize(tokens):
return "".join(
space + '\n' if tokval == '\r\n' else space + tokval
for space, tokval in tokens
)
class Rule( unasync.Rule ):
def __init__( self, fromdir, todir, suffix ) -> None:
self.suffix = suffix
super().__init__( fromdir, todir )
def _outfilepath( self, filepath ):
path = Path( self.todir ).absolute() / f'{Path(filepath).stem}{self.suffix}.py'
#assert False, f'{filepath=} {path=} {os.path.dirname(str(path))=}'
return str( path )
def _unasync_file( self, filepath ):
with open(filepath, "rb") as f:
write_kwargs = {}
if sys.version_info[0] >= 3:
encoding, _ = std_tokenize.detect_encoding(f.readline)
write_kwargs["encoding"] = encoding
f.seek(0)
tokens = _tokenize(f)
tokens = self._unasync_tokens(tokens)
result = _untokenize(tokens)
outfilepath = self._outfilepath( filepath )
_makedirs_existok(os.path.dirname(outfilepath))
with open(outfilepath, "w", **write_kwargs) as f:
print(result, file=f, end="")
rule = Rule( '.', '.', '_sync' )
rule._unasync_file( 'esl.py' )
- 主要语言
- Python
- 星标
- 108
- 派生
- 16
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
python-trio/unasync 的其他 Issue
-
难度 3/5 1-2 天 新手友好度 48/100
python-trio/unasync#79 · 1 条评论 ·
-
难度 4/5 3-5 天 新手友好度 35/100
python-trio/unasync#74 · 4 条评论 · 1 个 reaction ·
-
JIT未关闭
难度 5/5 一周以上 新手友好度 20/100
python-trio/unasync#72 · 3 条评论 ·
-
难度 3/5 1-2 天 新手友好度 45/100
python-trio/unasync#69 · 1 条评论 · 1 个 reaction ·
-
难度 4/5 3-5 天 新手友好度 35/100
python-trio/unasync#68 · 2 条评论 · 2 个 reaction ·
查看 python-trio/unasync 的全部 Issue
相似的 Issue
-
feedback simulation workshop
难度 2/5 1-3 小时 新手友好度 73/100
githubnext/gh-aw-workshop#4455 ·
维护者通常 1 天内回复
-
Triage 🩺
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
[BUG] Container scenario crashes without expected_recovery_time, kube DNS example uses retry_wait未关闭needs-triage
难度 2/5 1-3 小时 新手友好度 77/100
krkn-chaos/krkn#1627 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
NousResearch/hermes-agent#136483 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 88/100
维护者通常 1 天内回复