Skip to content

[DOC] fix erronously named option "user" to "owner" in the docstring of "files.find" in salt/modules/files.py #67912

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

dnessett
Copy link

@dnessett dnessett commented Mar 22, 2025

What does this PR do?

Fixes a documentation error in salt/modules/files.py. Specifically, it corrects the erroneously named option "user" to "owner".

What issues does this PR fix or reference?

[Doc] 67911

Merge requirements satisfied?

[NOTICE] Bug fixes or features added to Salt require tests.

Commits signed with GPG?

No

associated with def find(path, *args, **kwargs) in file.py
@dnessett dnessett requested a review from a team as a code owner March 22, 2025 23:09
twangboy
twangboy previously approved these changes Mar 26, 2025
@dmurphy18 dmurphy18 changed the title fix erronously named option "user" to "owner" in the docstring of "files.find" in salt/modules/files.py [DOC] fix erronously named option "user" to "owner" in the docstring of "files.find" in salt/modules/files.py Mar 26, 2025
@dmurphy18 dmurphy18 added this to the Argon v3008.0 milestone Mar 26, 2025
@dmurphy18 dmurphy18 added Documentation Relates to Salt documentation doc-correction docu page has an error or deadlink and removed doc-correction docu page has an error or deadlink labels Mar 26, 2025
@whytewolf
Copy link
Collaborator

you need to fix pre-commit.

@dnessett
Copy link
Author

you need to fix pre-commit.

Happy too. But, I don't know what the problem is. Do I execute pre-commit install again? Do I reinstall pre-commit with apt?

@whytewolf
Copy link
Collaborator

you need to fix pre-commit.

Happy too. But, I don't know what the problem is. Do I execute pre-commit install again? Do I reinstall pre-commit with apt?

nothing that drastic. this is the issue.

 fix end of files.........................................................Failed
- hook id: end-of-file-fixer
- exit code: 1
- files were modified by this hook

Fixing changelog/67911.fixed.md

most likely you either had too many lines. or didn't have a line ending on the end of the file.

@dnessett
Copy link
Author

dnessett commented Apr 14, 2025

you need to fix pre-commit.

Happy too. But, I don't know what the problem is. Do I execute pre-commit install again? Do I reinstall pre-commit with apt?

nothing that drastic. this is the issue.

 fix end of files.........................................................Failed
- hook id: end-of-file-fixer
- exit code: 1
- files were modified by this hook

Fixing changelog/67911.fixed.md

most likely you either had too many lines. or didn't have a line ending on the end of the file.

I failed to install pre-commit to the branch containing the fixes for 67911. I did that, added an end of line to the file salt/modules/file.py, did a git add for file.py then committed. Pre-install then ran during the commit, but it output the following:

(salt) dan@Eclipse-Salt:~/SaltSource/bugfix-67911/salt$ git commit
check for merge conflicts................................................Passed
trim trailing whitespace.................................................Passed
mixed line ending........................................................Passed
fix end of files.........................................................Failed
- hook id: end-of-file-fixer
- exit code: 1
- files were modified by this hook

Fixing salt/modules/file.py

I don't know if the output "Fixing salt/modules/file.py" means pre-commit fixed the problem or if "fix end of files.........................................................Failed" means there is still a problem. I need some guidance on this before I do the push to my repo on GitHub.

@dnessett
Copy link
Author

OK, I looked at file.py after pre-commit ran and it deleted the newline after the last non-empty line in the file. So, I must have misinterpreted, "most likely you either had too many lines. or didn't have a line ending on the end of the file." Can you explain or point me to the requirements for end-of-file on salt files?

@twangboy
Copy link
Contributor

I think we require a single new line at the end of python files.

@dnessett
Copy link
Author

I think we require a single new line at the end of python files.

Thanks. That is what I thought. However, I added a single blank line at the end of file.py (which didn't have one) and it seems pre-commit removed it when I committed the change. Also after pre-commit runs, the commit doesn't and file.py is in a strange state in which it is listed as "Changes to be committed:" as well as "Changes not staged for commit:". Here is the record showing this:

(salt) dan@Eclipse-Salt:~/SaltSource/bugfix-67911/salt/salt/modules$ git status
On branch bugfix-67911
nothing to commit, working tree clean
(salt) dan@Eclipse-Salt:~/SaltSource/bugfix-67911/salt/salt/modules$ tail -5 file.py

            total_size += stat_structure.st_size

    ret = total_size
    return ret
(salt) dan@Eclipse-Salt:~/SaltSource/bugfix-67911/salt/salt/modules$ vi file.py
(salt) dan@Eclipse-Salt:~/SaltSource/bugfix-67911/salt/salt/modules$ tail -5 file.py
            total_size += stat_structure.st_size

    ret = total_size
    return ret

(salt) dan@Eclipse-Salt:~/SaltSource/bugfix-67911/salt/salt/modules$ git add file.py
(salt) dan@Eclipse-Salt:~/SaltSource/bugfix-67911/salt/salt/modules$ git commit
check for merge conflicts................................................Passed
trim trailing whitespace.................................................Passed
mixed line ending........................................................Passed
fix end of files.........................................................Failed
- hook id: end-of-file-fixer
- exit code: 1
- files were modified by this hook

Fixing salt/modules/file.py

<elided most of pre-commit output>

Lint Salt................................................................Passed
Lint Tests...........................................(no files to check)Skipped
(salt) dan@Eclipse-Salt:~/SaltSource/bugfix-67911/salt/salt/modules$ git status
On branch bugfix-67911
Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
	modified:   file.py

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	modified:   file.py

(salt) dan@Eclipse-Salt:~/SaltSource/bugfix-67911/salt/salt/modules$ tail -5 file.py

            total_size += stat_structure.st_size

    ret = total_size
    return ret
(salt) dan@Eclipse-Salt:~/SaltSource/bugfix-67911/salt/salt/modules$ 

@whytewolf
Copy link
Collaborator

whytewolf commented Apr 15, 2025

I think we require a single new line at the end of python files.

Thanks. That is what I thought. However, I added a single blank line at the end of file.py (which didn't have one) and it seems pre-commit removed it when I committed the change. Also after pre-commit runs, the commit doesn't and file.py is in a strange state in which it is listed as "Changes to be committed:" as well as "Changes not staged for commit:". Here is the record showing this:

(salt) dan@Eclipse-Salt:~/SaltSource/bugfix-67911/salt/salt/modules$ git status
On branch bugfix-67911
nothing to commit, working tree clean
(salt) dan@Eclipse-Salt:~/SaltSource/bugfix-67911/salt/salt/modules$ tail -5 file.py

            total_size += stat_structure.st_size

    ret = total_size
    return ret
(salt) dan@Eclipse-Salt:~/SaltSource/bugfix-67911/salt/salt/modules$ vi file.py
(salt) dan@Eclipse-Salt:~/SaltSource/bugfix-67911/salt/salt/modules$ tail -5 file.py
            total_size += stat_structure.st_size

    ret = total_size
    return ret

(salt) dan@Eclipse-Salt:~/SaltSource/bugfix-67911/salt/salt/modules$ git add file.py
(salt) dan@Eclipse-Salt:~/SaltSource/bugfix-67911/salt/salt/modules$ git commit
check for merge conflicts................................................Passed
trim trailing whitespace.................................................Passed
mixed line ending........................................................Passed
fix end of files.........................................................Failed
- hook id: end-of-file-fixer
- exit code: 1
- files were modified by this hook

Fixing salt/modules/file.py

<elided most of pre-commit output>

Lint Salt................................................................Passed
Lint Tests...........................................(no files to check)Skipped
(salt) dan@Eclipse-Salt:~/SaltSource/bugfix-67911/salt/salt/modules$ git status
On branch bugfix-67911
Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
	modified:   file.py

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	modified:   file.py

(salt) dan@Eclipse-Salt:~/SaltSource/bugfix-67911/salt/salt/modules$ tail -5 file.py

            total_size += stat_structure.st_size

    ret = total_size
    return ret
(salt) dan@Eclipse-Salt:~/SaltSource/bugfix-67911/salt/salt/modules$ 

pre-commit can be finicky to work with. what i normally do is instead of committing right away. i run git add . command then run pre-commit manually. if it does changes i then run git add . again after and rerun pre-commit again. once pre-commit runs clean i will then commit the change. this lets me make sure each commit passes pre-commit.

pre-commit will make some changes to files. but it doesn't add them to the commit on its own. so you have to account for it when working with it and git.

@dnessett
Copy link
Author

dnessett commented Apr 15, 2025

pre-commit can be finicky to work with. what i normally do is instead of committing right away. i run git add . command then run pre-commit manually. if it does changes i then run git add . again after and rerun pre-commit again. once pre-commit runs clean i will then commit the change. this lets me make sure each commit passes pre-commit.

pre-commit will make some changes to files. but it doesn't add them to the commit on its own. so you have to account for it when working with it and git.

I tried your suggestion. pre-commit ran and deleted the newline at the end of file.py. Then I ran pre-commit again and it passed. However, git status showed no files modified, so I couldn't add file.py and do the commit. Is it possible that pre-commit doesn't want a newline at the end of the file? If so, the failure of pre-commit when running the PR is hard to understand. Might the version of pre-commit which runs for the PR not be the same as the version of pre-commit installed on linux using apt? The version installed on my linux machine is 4.0.1

@whytewolf
Copy link
Collaborator

whytewolf commented Apr 15, 2025

pre-commit can be finicky to work with. what i normally do is instead of committing right away. i run git add . command then run pre-commit manually. if it does changes i then run git add . again after and rerun pre-commit again. once pre-commit runs clean i will then commit the change. this lets me make sure each commit passes pre-commit.
pre-commit will make some changes to files. but it doesn't add them to the commit on its own. so you have to account for it when working with it and git.

I tried your suggestion. pre-commit ran and deleted the newline at the end of file.py. Then I ran pre-commit again and it passed. However, git status showed no files modified, so I couldn't add file.py and do the commit. Is it possible that pre-commit doesn't want a newline at the end of the file? If so, the failure of pre-commit when running the PR is hard to understand. Might the version of pre-commit which runs for the PR not be the same as the version of pre-commit installed on linux using apt? The version installed on my linux machine is 4.0.1

precommit in the PR isn't failing on file.py. it is failing on your changelog.

also once you get a pre-commit to run clean and git add works. and you get a commit in place. don't forget to push to github. the PR won't update till you do the push.

@dnessett
Copy link
Author

dnessett commented Apr 15, 2025

precommit in the PR isn't failing on file.py. it is failing on your changelog.

also once you get a pre-commit to run clean and git add works. and you get a commit in place. don't forget to push to github. the PR won't update till you do the push.

I looked at the changelog entry for 67911 ( 67911.fixed.md on https://github.com/dnessett/salt/ - changelog directory for branch bug fix-67911 - from which I did the pull request) and it does not have a newline after the changelog description. I then looked at the file on my local machine and it does have a newline after the description. So, I am speculating that running pre-commit on the PR side deleted the newline from the changelog file on my local repository on GitHub. I cannot commit the local file and push it, since git detects no changes to its content. pre-commit on my local machine does not complain that there is a newline after the description on 67911.fixed.md, which is puzzling. I am now completely confused.

@whytewolf
Copy link
Collaborator

precommit in the PR isn't failing on file.py. it is failing on your changelog.
also once you get a pre-commit to run clean and git add works. and you get a commit in place. don't forget to push to github. the PR won't update till you do the push.

I looked at the changelog entry for 67911 ( 67911.fixed.md on https://github.com/dnessett/salt/ - changelog directory for branch bug fix-67911 - from which I did the pull request) and it does not have a newline after the changelog description. I then looked at the file on my local machine and it does have a newline after the description. So, I am speculating that running pre-commit on the PR side deleted the newline from the changelog file on my local repository on GitHub. I cannot commit the local file and push it, since git detects no changes to its content. pre-commit on my local machine does not complain that there is a newline after the description on 67911.fixed.md, which is puzzling. I am now completely confused.

you have most likely rerun pre-commit so many times at this point that it is fixed in your local system. don't think about what it is trying to do and just let it do it.

@dnessett
Copy link
Author

you have most likely rerun pre-commit so many times at this point that it is fixed in your local system. don't think about what it is trying to do and just let it do it.

Thinking about this, to get my local system in sync with the repo branch, should I delete the newline on my local system changelog entry, git add that entry, run pre-commit until it is satisfied then commit the change and finally push the result? This will not change the file on my local repository, but will get my local machine and repo in sync.

@whytewolf
Copy link
Collaborator

what does git status give? without touching anything.

@dnessett
Copy link
Author

dnessett commented Apr 15, 2025

what does git status give? without touching anything.

(salt) dan@Eclipse-Salt:~/SaltSource/bugfix-67911/salt$ git status
On branch bugfix-67911
nothing to commit, working tree clean
(salt) dan@Eclipse-Salt:~/SaltSource/bugfix-67911/salt$

@whytewolf
Copy link
Collaborator

weird ... your git isn't tracking upstream?

output of these?

git branch -vv
git rev-parse --symbolic-full-name "@{u}"

@dnessett
Copy link
Author

dnessett commented Apr 16, 2025

weird ... your git isn't tracking upstream?

output of these?

git branch -vv
git rev-parse --symbolic-full-name "@{u}"

(salt) dan@Eclipse-Salt:~/SaltSource/bugfix-67911/salt$ git branch -vv
  3006.x       685d330cc0 [origin/3006.x] Fix some lint
* bugfix-67911 804be91e20 Merge branch 'master' into bugfix-67911
  master       c672f97fe0 [origin/master] Merge branch 'saltstack:master' into master
(salt) dan@Eclipse-Salt:~/SaltSource/bugfix-67911/salt$ git rev-parse --symbolic-full-name "@{u}"
fatal: no upstream configured for branch 'bugfix-67911'
(salt) dan@Eclipse-Salt:~/SaltSource/bugfix-67911/salt$ 

It seems I forgot to set upstream for the branch.

Actually, I did but set it to saltstack/salt

git remote add upstream https://github.com/saltstack/salt.git

@whytewolf
Copy link
Collaborator

whytewolf commented Apr 16, 2025

looks like bugfix-67911 is not set to track origin/bugfix-67911

git branch --set-upstream-to origin/bugfix-67911 should fix that

also next time you create a new branch locally use -u when you push it for the first time to origin. that will set git to track the github version and see differences between origin and local

@dnessett
Copy link
Author

looks like bugfix-67911 is not set to track origin/bugfix-67911

git branch --set-upstream-to origin/bugfix-67911 should fix that

also next time you create a new branch locally use -u when you push it for the first time to origin. that will set git to track the github version and see differences between origin and local

OK. Thanks,

FYI. I have to step a way for several hours.

@dnessett
Copy link
Author

dnessett commented Apr 16, 2025

I executed git branch --set-upstream-to origin/bugfix-67911, as suggested. then executed git fetch upstream. My local copy of salt/changelog/67911.fixed.md was still out of sync with the repo copy having no extra line at its end, whereas my local copy did. So, I deleted the extra line from my local copy, git added it, commit-ed the change and then pushed to my local repo. This sync'd the local and repo copies of bugfix-6791.

I think the reason the git fetch did not sync the two copies is when the PR pre-commit ran, it changed the copy of 67911.fixed.md on my repo without using git commit logic. This caused the two copies to go out of sync. The git fetch upstream (I am speculating here) doesn't do a complete diff of the local and repo copies, so whengit fetch upstream was executed, there were no differences in the commit history, so git thinks both copies are in sync. Hence the necessity of manually fixing the problem.

@whytewolf
Copy link
Collaborator

so, about your speculation.

about what fetch does.
"Fetch branches and/or tags (collectively, "refs") from one or more other repositories, along with the objects necessary to complete their histories. Remote-tracking branches are updated (see the description of below for ways to control this behavior)."

notice that it only lists remote-tracking branches as being updated. other wise it just downloads the meta data for branchs/tags. as noted your bugfix-67911 local branch wasn't tracking a remote. so it wouldn't be syncing. you also were fetching upstream, your github account is origin not upstream. personally I use git fetch --all if i use git fetch which is also rare.

so what happened. your local copy was not tracking origin. you made updates. then didn't push those updates to origin. so they came out of sync. then started into a cycle of git commit, git fetch. trying to understand what was happening. but since git fetch doesn't do anything for local branches that are not tracking the git fetch did absolutely nothing.

so just remember. git commit, then git push. so that you upload your local changes to the origin remote. also make sure your local branch IS tracking a remote branch. [there are reasons, and times when a local branch shouldn't track a remote branch, but that is way beyond this advice.]

git fetch is for when you want to pull from remote before doing a rebase or merge.

@dnessett
Copy link
Author

so, about your speculation.

about what fetch does. "Fetch branches and/or tags (collectively, "refs") from one or more other repositories, along with the objects necessary to complete their histories. Remote-tracking branches are updated (see the description of below for ways to control this behavior)."

notice that it only lists remote-tracking branches as being updated. other wise it just downloads the meta data for branchs/tags. as noted your bugfix-67911 local branch wasn't tracking a remote. so it wouldn't be syncing. you also were fetching upstream, your github account is origin not upstream. personally I use git fetch --all if i use git fetch which is also rare.

so what happened. your local copy was not tracking origin. you made updates. then didn't push those updates to origin. so they came out of sync. then started into a cycle of git commit, git fetch. trying to understand what was happening. but since git fetch doesn't do anything for local branches that are not tracking the git fetch did absolutely nothing.

so just remember. git commit, then git push. so that you upload your local changes to the origin remote. also make sure your local branch IS tracking a remote branch. [there are reasons, and times when a local branch shouldn't track a remote branch, but that is way beyond this advice.]

git fetch is for when you want to pull from remote before doing a rebase or merge.

Thanks for the explanation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Relates to Salt documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants