Repository navigation
add trio240, usage of os.path in async function - #100
Merged
Merged
Conversation
jakkdl
force-pushed
the
os_path_in_async_function
branch
from
January 13, 2023 12:39
aa5572e to
d9a090e
Compare
10 of 12 tasks
Zac-HD
reviewed
Jan 14, 2023
| if not self.async_function: | ||
| return | ||
| func_name = ast.unparse(node.func) | ||
| if func_name.startswith("os.path."): |
Member
There was a problem hiding this comment.
Alas, I suspect that requiring rewrites for all code that calls os.path.join() (and other pure functions) is not going to be viable, so we'll need to read through https://docs.python.org/3/library/os.path.html and work out the list.
Member
Author
There was a problem hiding this comment.
Read through the source code, and came up with this list
safe = (
"_get_sep",
"_varprog",
"_varprogb",
"normcase",
"isabs",
"join",
"split",
"splitext",
"splitdrive",
"basename",
"dirname",
"expanduser",
"commonpath",
"expandvars", # os.fsencode, os.environ, os.fsdecode
"abspath", # calls, os.getcwd, which I think python tracks internally?
"commonprefix",
"samestat", # just does simple equality check
# constants
"curdir",
"pardir",
"extsep",
"sep",
"pathsep",
"defpath",
"altsep",
"devnull",
"supports_unicode_filenames",
)
os_funcs = (
"_path_normpath",
"normpath",
"_joinrealpath",
"islink",
"lexists",
"ismount", # safe on windows, unsafe on posix
"realpath",
"exists",
"isdir",
"isfile",
"getatime",
"getctime",
"getmtime",
"getsize",
"samefile",
"sameopenfile",
"relpath",
)
jakkdl
force-pushed
the
os_path_in_async_function
branch
2 times, most recently
from
January 14, 2023 20:17
142ac0a to
32c2706
Compare
Member
Author
|
Updated with explicit list of functions, also realized that looking for imports is easy - and might be somewhat common, so it will now catch that as well. |
jakkdl
force-pushed
the
os_path_in_async_function
branch
from
January 14, 2023 20:20
32c2706 to
46b3fef
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
First bullet point of path manipulation in #58
Suspect this may be overly broad or trigger false alarms, but we'll see.