I downloaded a repo with git on PyCharm and many of the indents on almost every single file are off - windows

I'm currently running Python 3.9, PyCharm 2021.1.3 with the Git client bundled, and when I pulled a repo for work, and almost every file has indents that are off, needing both indents and dedents. Has anyone ran into this problem before? I've attached a small screenshot from one of the init functions in one of the classes to demonstrate what it is I received when I cloned and downloaded.

Yes, the author of the code has mixed spaces and tabs.
You can see def __init__ at the first line has one level of indentation, probably with a tab.
self._cp at line 2 must have two levels of indentation,
probably two spaces each.
If the code runs correctly, all you need to do is reformat the file.
The default keyboard shortcut is:
Ctrl+Alt+s

Related

Lines of code automatically added without warning/consent

**edited tags to reflect the cause of the problem
I've been working with Node.js for about 3 months give or take, and today I was working on a project when I suddenly got an import error on the client side, even though I hadn't touched any code there since I last ran the program. In fact, the only changes I had made were on the server side, and it was just some minor refactoring that didn't have anything to do with the imports. After frantically trying to find what I'd done, I scrolled up to see this line in server/index.js:
const { default: socket } = require('../client/src/socket.js');
I didn't write this line. It had been added without me asking or even noticing that it was there. I'm pretty sure that I hadn't clicked on any formatting tooltips, and it seemed to appear out of nowhere and was the cause of the break.
This isn't the first time that this has happened to me. I have noticed that at sporadic moments, code is added to my projects that I never asked for. So I have some questions:
Is this a feature of Node, and if so what triggers it?
As I'm using VScode, is it rather the IDE that's doing this?
How do I stop whatever's causing this from trying, and failing, to be helpful?
Thanks.
This is most likely VSCode's built-in auto-imports. You've probably typed socket and selected an auto-suggestion which contained Auto import from "../client/src/socket.js"
You can disable it with the setting "javascript.suggest.autoImports": false.
Additionally, if you're using Git for version control, try using git add -p (-p for patch) to stage your changes bit by bit instead of the entire file. This way you can review your changes in slices and you'll probably catch things like this.
That's not a feature of Node but, Some of the VSCode extensions possess capabilities of auto import. Maybe one of your extension has added that line. To prevent it disable your JavaScript autocomplete, linter extensions.

project.vim reports "is not a valid directory" when refreshing or creating a project

I'm using project.vim with VIm to manage large code bases with deep directory structures.
When I switch to another one or create (\C) a new one and do a refresh (\R) project.vim starts displaying messages through the whole process for different directories:
<dir_name> is not a valid directory. [O]K:
I have to press Enter all the time, although the directories exist. I took a look at the code and it checks if the path is a directory. They are.
Maybe there is a fix for this. The directories are under Perforce management, so everything is read-only.
I have to stay at the keyboard and keep pressing Enter for it to go to next directories... For large code bases this is takes a long time.
I contacted the author some time ago, but there was no response.
Did anyone encounter this before?
Could it be the it is bothered by the read-only-ness?
Is there a fix for this?
Thanks
The plugin uses glob() for some of those directory checks, which is affected by the 'wildignore' setting. Try
:set wildignore=
If that fixes the problem (and you have at least Vim version 7.2.51), you can modify the plugin's code to use glob(..., 1) instead.

Git is seeing changes I didn't make in xcode

I'm programming in xcode (actually Phone Gap in conjunction with xcode) with git. I'm having a strange issue. When I create two identical branches and try to check out back and fourth between them with out making any changes git is telling me that I need to commit because a change has been made (this same thing is also resulting in merge conflicts). It says the changed file is:
platforms/ios/Butterfli.xcodeproj/project.xcworkspace/xcuserdata/benpearce.xcuserdatad/UserInterfaceState.xcuserstate
Can anyone explain what's going on and how to deal with it.
Yes, .xcworkspaces are simply files that Xcode uses to describe the workspace or projects.
IMHO, There's no need to check these files in at all, unless you share settings with other folks in your projects (and in your case, I suppose other machines that have a user named "benpearce").
In fact, you can safely add them to your .gitignore file.
More info can be seen here

Github windows, whole file shows change after commit.

I am using the github windows app. I seem to be having problems with it showing what has changed and what hasn't. Before I commit it correctly shows only the changed lines, but after I commit, it shows that all the lines have changed in the file. Any way to get it to stop this?
It is quite annoying and any help would be appreciated.
ps, i made sure that their are no line ending issues.
This is usual core.autocrlf issue (different setting in your clients and definitely wrong in Github client) - read "Formatting and Whitespace" topic and core.autocrlf part of it carefully
PS: you can test my statement using differ, which can ignore EOL-difference in compared files

SVN diff flagging all lines of code as new when PC programmer updates file recently committed by Mac Programmer

Here's the scenario I'm currently running into:
Programmer A (Using a Mac Version of Dreamweaver) edits file client.php and commits that file to the production branch of Project Foo's repository
Programmer B (Using a Windows Version of Dreamweaver) edits file client.php to fix a bug in the that file. He then does a cp clientInfo.php ../prod-branch/clientInfo.php to take that bug-fix from his working copy to the production branch.
Programmer B then does an svn diff ../prod-branch/clientInfo.php to see what svn says his changes were only to discover that svn says he's changed every line in the file!
Now, this is what I believe is happening:
When the file gets edited by Mac, Dreamweaver on Mac replaces all the Windows newline characters with Mac newline characters so that it's readable in Dreamweaver. In short, Dreamweaver has altered every line in the file. Now, once the commit is done, svn sees that every line of the file has changed and marks this fact down. When the windows programmer makes a change and the newline characters get changed again, svn thinks that, again, every line has changed.
My question is this: How can we prevent this from happening? I know there's no way to undo the damage that's already been done, but I want to prevent this from happening in the future.
You need to use the "svn:eol-style" property on all text files. Usually setting it to "native" will suffice
Dreamweaver has an option to set which line break type it uses. Edit (on Mac: Dreamweaver ) -> Preferences, Code Format, Line break type.
Get your users to have the same setting, and things should play a little better together. It would be better, of course, if you can set your source control to ignore line break differences.
svn:eol-style is a property that can be set centrally in the repository and should sort out your problem.
Check out the chapter on New Line Sequences in the Subversion book.
The solution to this problem is the svn:eol-style property. When this property is set to a valid value, Subversion uses it to determine what special processing to perform on the file so that the file's line ending style isn't flip-flopping with every commit that comes from a different operating system. The valid values are:

Resources