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

Unix: Fallback to default if XDG environment variable is empty #30

Merged
merged 8 commits into from
Jul 29, 2021

Conversation

papr
Copy link
Contributor

@papr papr commented Jul 28, 2021

Fixes #29 using https://github.com/pypa/pip/blob/867bbb00ccb0506095e19a0e111ce06ce71a2495/tools/vendoring/patches/appdirs.patch#L47-L54 as a reference implementation.

Open questions:

  • How to test this properly?
  • How to test compatibility with appdirs if appdirs is not implementing this behavior?

Todo:

  • Tests
  • Changelog

@codecov-commenter
Copy link

codecov-commenter commented Jul 28, 2021

Codecov Report

Merging #30 (9543cb1) into main (f9c2074) will increase coverage by 3.18%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #30      +/-   ##
==========================================
+ Coverage   90.70%   93.89%   +3.18%     
==========================================
  Files          12       13       +1     
  Lines         495      524      +29     
  Branches       44       44              
==========================================
+ Hits          449      492      +43     
+ Misses         32       26       -6     
+ Partials       14        6       -8     
Flag Coverage Δ
tests 93.51% <100.00%> (+3.20%) ⬆️

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

Impacted Files Coverage Δ
src/platformdirs/unix.py 96.82% <100.00%> (+22.22%) ⬆️
tests/test_unix.py 100.00% <100.00%> (ø)

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 f9c2074...9543cb1. Read the comment docs.

src/platformdirs/unix.py Outdated Show resolved Hide resolved
@papr
Copy link
Contributor Author

papr commented Jul 28, 2021

I will need help with the failing type checks. I am able to run tox -e type but it is raising more errors than logged in the Github Actions. Some of them affect files that I did not change here but in #27 where the type check ran successfully. What am I missing?

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

@gaborbernat gaborbernat left a comment

Choose a reason for hiding this comment

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

I agree of inline-ing the new functionality, because we don't want to call the expesnive relatively os.path.expanduser unless we must. The tests just needed some type annotation, and you cannot use the Platformdir class directly as type because is dynamically calculated and mypy cannot deduce it. You'd need to type it as the ABC variant, but in this case we can just always run the tests on all platforms and annotate it as Unix, because the functionality you've added is tied to the Unix class, not anything else in the __init__.py file.

@gaborbernat gaborbernat requested a review from ofek July 28, 2021 23:25
Signed-off-by: Bernát Gábor <[email protected]>
@gaborbernat gaborbernat merged commit 0a61690 into tox-dev:main Jul 29, 2021
@papr papr deleted the fix-#29 branch July 29, 2021 07:49
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.

Linux: Empty environment variables should use defaults
4 participants