Skip to content

Improve test suite, reorganize to platform classes - #26

Merged
gaborbernat merged 10 commits into
tox-dev:mainfrom
gaborbernat:main
Jul 22, 2021
Merged

gaborbernat merged 10 commits into
tox-dev:mainfrom
gaborbernat:main

Conversation

@gaborbernat

@gaborbernat gaborbernat commented Jul 20, 2021 •

Copy link
Copy Markdown
Member

Managed to close #25 by mistake so opening again.

gaborbernat and others added 2 commits July 20, 2021 10:34
Signed-off-by: Bernát Gábor <[email protected]>
@codecov-commenter

codecov-commenter commented Jul 20, 2021 •

Copy link
Copy Markdown

Codecov Report

Merging #26 (2f20866) into main (9735757) will increase coverage by 5.94%.
The diff coverage is 87.17%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #26      +/-   ##
==========================================
+ Coverage   83.69%   89.64%   +5.94%     
==========================================
  Files           7       12       +5     
  Lines         411      425      +14     
  Branches       85       43      -42     
==========================================
+ Hits          344      381      +37     
+ Misses         47       31      -16     
+ Partials       20       13       -7     
Flag Coverage Δ
tests 89.17% <86.58%> (+5.96%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/platformdirs/windows.py 66.29% <66.29%> (ø)
src/platformdirs/unix.py 73.07% <73.07%> (ø)
src/platformdirs/__init__.py 100.00% <100.00%> (+21.26%) ⬆️
src/platformdirs/android.py 100.00% <100.00%> (ø)
src/platformdirs/api.py 100.00% <100.00%> (ø)
src/platformdirs/macos.py 100.00% <100.00%> (ø)
tests/conftest.py 100.00% <100.00%> (ø)
tests/test_android.py 100.00% <100.00%> (ø)
tests/test_api.py 100.00% <100.00%> (ø)
tests/test_comp_with_appdirs.py 100.00% <100.00%> (ø)
... and 6 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9735757...2f20866. Read the comment docs.

@gaborbernat gaborbernat changed the title main Improve test suite, reorganize to platform classes Jul 20, 2021
@gaborbernat
gaborbernat marked this pull request as ready for review July 20, 2021 13:49
Comment thread src/platformdirs/unix.py
path = os.environ["XDG_DATA_DIRS"]
else:
path = f"/usr/local/share{os.pathsep}/usr/share"
return self._with_multi_path(path)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

why not work with split paths here and only join the result

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Can you detail? I've just kept the existing method, but we can switch if you propose something better.

Comment thread src/platformdirs/windows.py Outdated

def _path_with_app_version(self, path: str, *, opinion_value: Optional[str] = None) -> str:
if self.appname:
assert self.appname is not None

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

this seems redundant at first glance

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Hmmm, kept existing logic, but yeah this can be removed.

Signed-off-by: Bernát Gábor <[email protected]>
@ofek

ofek commented Jul 20, 2021

Copy link
Copy Markdown
Collaborator

This looks fine but I'd much prefer to keep the conditional detection logic. I have a bias b/c I write a lot of CLIs where load times are important, but really why should we import every module at the root when only one will be used?

@gaborbernat

gaborbernat commented Jul 20, 2021 •

Copy link
Copy Markdown
Member Author

This looks fine but I'd much prefer to keep the conditional detection logic. I have a bias b/c I write a lot of CLIs where load times are important, but really why should we import every module at the root when only one will be used?

Can you provide some metrics of a performance difference? I don't think there's a significant difference in importing three small files. What you're talking about is premature optimization?

@ofek

ofek commented Jul 20, 2021

Copy link
Copy Markdown
Collaborator

Not an issue currently, but we'd have to careful with imports in each module. Say for example we're on not-Android and a new Python release made importing functools slower, things like that.

premature optimization

I don't think so as the 2 approaches are so different that going back to the current one by removing .is_active methods would be a breaking change.

@gaborbernat

Copy link
Copy Markdown
Member Author

I don't think so as the 2 approaches are so different that going back to the current one by removing .is_active methods would be a breaking change.

I'd definitely keep is_active. At that point, you'd have different solutions to use import functools locally where it's needed.

@gaborbernat

Copy link
Copy Markdown
Member Author

@ofek added d94e998 to achieve a similar functionality 👍

Signed-off-by: Bernát Gábor <[email protected]>

@ofek ofek left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This looks much nicer ty 😄

Signed-off-by: Bernát Gábor <[email protected]>
Signed-off-by: Bernát Gábor <[email protected]>
Comment thread docs/api.rst Resolved
Comment thread src/platformdirs/unix.py Resolved
Comment thread src/platformdirs/macos.py Resolved
Signed-off-by: Bernát Gábor <[email protected]>
Comment thread src/platformdirs/macos.py Resolved
@RonnyPfannschmidt

Copy link
Copy Markdown

Unfortunately im quite stretched today and can't give this quite the time it deserves

Comment thread src/platformdirs/api.py Resolved
Comment thread src/platformdirs/api.py Resolved
Comment thread src/platformdirs/api.py Resolved
Comment thread src/platformdirs/api.py Resolved
Comment thread src/platformdirs/api.py Resolved
Comment thread src/platformdirs/api.py Resolved
Comment thread src/platformdirs/api.py Resolved
Comment thread src/platformdirs/macos.py
class MacOS(PlatformDirsABC):
"""
Platform directories for the macOS operating system. Follows the guidance from `Apple documentation
<https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/MacOSXDirectories/MacOSXDirectories.html>`_.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you move the URL to the end of the parragraph as done here?

This helps keep the docstring more readable in it's raw format.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I disagree in this instance, I prefer to keep links inline 👍

Comment thread src/platformdirs/macos.py Resolved
Comment thread src/platformdirs/macos.py Resolved
Comment thread tox.ini Resolved
Signed-off-by: Bernát Gábor <[email protected]>
@gaborbernat
gaborbernat merged commit 6fe8168 into tox-dev:main Jul 22, 2021
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.

5 participants