Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Sep 5, 2025

The get_curdir function in capybara/utils/custom_path.py was not respecting the absolute parameter. When called with absolute=False, it still returned an absolute path instead of a relative path.

Problem:
The issue was on line 23 where .resolve() was called unconditionally:

return path.parent.resolve()  # Always returns absolute path

As shown in the issue screenshot, both calls returned the same absolute path:

get_curdir(__file__)                    # PosixPath('/home/jack/workspace/...')
get_curdir(__file__, absolute=False)    # PosixPath('/home/jack/workspace/...') ❌

Solution:
Changed the return statement to conditionally call .resolve() based on the absolute parameter:

return path.parent.resolve() if absolute else path.parent

After the fix:

  • get_curdir(path, absolute=True) returns absolute path (unchanged behavior)
  • get_curdir(path, absolute=False) now correctly returns relative path

This ensures backward compatibility since all existing usage in the codebase uses the default absolute=True parameter.

Fixes #29.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copy link
Contributor Author

Copilot AI commented Sep 5, 2025

@kunkunlin1221 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs.

I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review.

…lute=True

Co-authored-by: kunkunlin1221 <26329816+kunkunlin1221@users.noreply.github.com>
Copilot AI changed the title [WIP] [BUG] get_curdir's absolute is not working. Fix get_curdir absolute parameter bug - conditional resolve() call Sep 5, 2025
Copilot AI requested a review from kunkunlin1221 September 5, 2025 02:35
@kunkunlin1221 kunkunlin1221 marked this pull request as ready for review September 5, 2025 03:19
@kunkunlin1221 kunkunlin1221 added the bug Something isn't working label Sep 5, 2025
@kunkunlin1221 kunkunlin1221 merged commit 0b2c034 into main Sep 5, 2025
18 checks passed
@kunkunlin1221 kunkunlin1221 deleted the copilot/fix-29 branch September 5, 2025 05:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] get_curdir's absolute is not working.

3 participants