Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

if source looks like a package add it to source_pkgs #1030

Closed
wants to merge 2 commits into from

Conversation

graingert
Copy link
Contributor

an alternative to #1026 in which ambiguous source definitions use the package and the dir

@graingert graingert marked this pull request as draft September 4, 2020 21:28
coverage/inorout.py Outdated Show resolved Hide resolved
@nedbat
Copy link
Owner

nedbat commented Sep 4, 2020

I don't understand what the re.match is trying to determine. Can you write a few sentences (docs?) about what this change does?

coverage/inorout.py Outdated Show resolved Hide resolved
@@ -108,6 +110,14 @@ def module_has_file(mod):
return os.path.exists(mod__file__)


_IS_PKG_RE = re.compile(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

on python3.8 _IS_PKG_RE is

re.compile(r"\A(((?!False|None|True|and|as|assert|async|await|break|class|continue|def|del|elif|else|except|finally|for|from|global|if|import|in|is|lambda|nonlocal|not|or|pass|raise|return|try|while|with|yield)\w+)\.?)+\Z")

Copy link
Contributor Author

@graingert graingert Sep 4, 2020

Choose a reason for hiding this comment

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

a bit like:

all(s.isidentifier() and not keyword.iskeyword(s) for s in v.split("."))

but s.isidentifier() is not on python2 and the RE is faster

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nedbat something like this?

Suggested change
_IS_PKG_RE = re.compile(
# a dot delimited string of names that are not keywords
_module_name_re = re.compile(

@nedbat
Copy link
Owner

nedbat commented Sep 5, 2020

This seems like too much guessing to me. And it would change the behavior of --source=foo from "assume directory" to "assume package".

@graingert
Copy link
Contributor Author

Yep, makes sense

@graingert graingert closed this Sep 5, 2020
@graingert graingert deleted the add-source-to-pkgs-and-dir branch September 5, 2020 12:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants