Skip to content

instead of valid_command() call command_path() for errors#87

Merged
zaihuaji merged 3 commits intomainfrom
hua-work-common
Mar 3, 2026
Merged

instead of valid_command() call command_path() for errors#87
zaihuaji merged 3 commits intomainfrom
hua-work-common

Conversation

@zaihuaji
Copy link
Copy Markdown
Collaborator

@zaihuaji zaihuaji commented Mar 3, 2026

No description provided.

Copilot AI review requested due to automatic review settings March 3, 2026 20:28
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates pg_log.py and pg_file.py to change how command path resolution is handled in two distinct ways:

  1. In pg_log.py, a new command_path() method is added that resolves a command's full path non-destructively (without caching or error logging), and is used in error messages within pgsystem() to display the full resolved path.
  2. In pg_file.py, all calls to self.valid_command(self.OBJCTCMD/self.BACKCMD, logact) are replaced with direct attribute access (self.OBJCTCMD / self.BACKCMD), since command validation is no longer the responsibility of the callers. A typo in a comment ("carrage" → "carriage") is also fixed.

Changes:

  • pg_log.py: Added command_path() method and used it (instead of valid_command()) for error message formatting in pgsystem(), plus a comment typo fix.
  • pg_file.py: Removed all valid_command() call wrappers around OBJCTCMD/BACKCMD, using the raw attribute values directly.
  • pyproject.toml: Version bumped from 2.0.18 to 2.0.19.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/rda_python_common/pg_log.py Adds command_path() method; applies it in pgsystem() error messages; fixes "carriage" comment typo
src/rda_python_common/pg_file.py Replaces self.valid_command(…) with direct attribute access for OBJCTCMD and BACKCMD
pyproject.toml Version bump to 2.0.19

There are two critical bugs introduced in pg_log.py:

  1. Line 673command_path(cmdstr) is called as a bare function, but it is an instance method. This will raise NameError at runtime every time pgsystem() encounters an error. It must be self.command_path(cmdstr).

  2. Line 877reutn is a SyntaxError (should be return). This will prevent the entire pg_log module from loading, breaking all functionality in the package.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/rda_python_common/pg_log.py Outdated
Comment thread src/rda_python_common/pg_log.py Outdated
zaihuaji and others added 2 commits March 3, 2026 14:34
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@zaihuaji zaihuaji merged commit b4fe356 into main Mar 3, 2026
1 check passed
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.

2 participants