VS code, django project have template errors, how to avoid them? - python

I have use autopep8 to check my Python error & warning in VS Code, and config the "Go to Next Problem in Files" to fast jump to the next one.
One day, I added one html file, found that the error list is long.
I do not care the html's error, cuz it is just test files. How can I avoid them?

I found one solution is that disable the HTML>Validate. Then the errors just from Python.

You could head to the settings.json and add this which will ignore validations in HTML files:
"html.validate.scripts": false,

Related

Openpyxl : Error message at the opening of the .xlsx created from a WorkBook that used wb.remove_sheet(ws)

Situation: I have model.xlsx, I delete 1 page, I save as output.xlsx. The page that I suppress have an image. There is no error raised.
Problem: when I try to open the file output.xlsx I have a first error message:
.
(Sorry: We have found a problem in the file <<output.xlsx>> but we can try to get back the maximum. If the source of the classifier reliable, click On Yes.)
And when I click on yes:
It says that it repaired the recording and it talks about images (so I suppose the images are the problem).
Then I have tricky errors (it delete the page but one other page that I try to duplicate doesn't keep track of the image).
Solution: I stopped using wb.remove_sheet(ws), now I use ws.sheet_state = 'hidden' and it works like a charm ! No problem to duplicate page with image and no error message at the openning of the file.
But it's system D ! (I want to delete the page, not hide it and pretend I did the job).
Am I doing something wrong ? Is this an error coming from the openpyxl library ?
Answer: System D because nobody answer, don't del it, just hide it.

Why is Pycharm not highlighting TODO's?

In my settings, I have the TODO bound to highlight in yellow, yet in the actual code it does not highlight. Here is a screenshot of my settings: Editor -> TODO
Does anyone know how to fix this?
EDIT: I even tried re-installing Pycharm and I still have the issue.
EDIT 2: In the TODO Window, it is saying "0 TODO items found in 0 files". I believe this means it is looking in the wrong files to check for TODO items. However, when I try to find TODO items in "this file" it still doesn't work. Does anyone know why this is?
Go to Preferences (or Settings), Project Structure, and make sure the folder with your files is not in the "Excluded" tab's list.
Click the folder you want to include and click on the "Sources" tab. Click Apply, then OK!
It should work.
I recently updated PyCharm Professional and my TODOs no longer worked. I went into settings and changed the alert icon, then saved, and retyped them and they worked. I imagine for my case, there was a delay in the new version picking them up. Might just need to retype them to get them working again, though the reboot should have addressed this.
Not sure if your pattern is causing this, but mine is set up like so, with two separate patterns:
\btodo\b.*
\bfixme\b.*
Neither is case sensitive, BTW...
Perhaps try some other patterns to see if you can get those to work.
I think the problem for me was the same as explained by #theBrownCoder but I couldn't find the project structure settings.
Apart from not showing TODO's another symptom was impossibility to go to function definitions defined in other files and inability to rename python files with the error: "Selected element is used from non-project files. These usages won't be renamed."
Googling for this the solution that worked for me was to delete the .idea folder (make sure to back it up just in case, you will lose the configurations).
I had the exact same problem, and the solution suggested by theBrownCoder worked perfectly.
For those who cannot find which menu theBrownCoder is referring to, go to File > Settings > Project: "Title of Project" > Project Structure.
It is in the dropdown of Project in Settings where you can also select your Python interpreter.
It might be the file type.
Right click, Override File Type.
I had this issue with a text file and it's copy, only the first one would use #TODO

Adding a link to windows directory under tags in Robot Framework

I'm currently working on the Robot Framework for some automated test cases, which included a couple of html screenshots I wrote on python.
I tried putting C:\Users\teo_y\Desktop\test directly under the tags for the test case, it still show the similar output instead of the link to my windows directory.
Instead of using the Tags, use the Documentation field. Use the Set Suite Documentation keyword if you want it dynamic.
Thank you for responding and helping out, I've found the solution to my problem.
As per Helio suggestion, i simply added a different line like the metadata [C:\Users\teo_y\Desktop\test|C:\Users\teo_y\Desktop\test] onto the documentation, and it turned out working the same outcome.
Thank you once again!
Cheers
Kia
https://i66.tinypic.com/kb97b8.png
https://i66.tinypic.com/102ntp1.png

How to ignore / omit / exclude files during test coverage?

In order to get 100% test coverage, I need to ignore some file(s) in python.
I searched the web and I found nosetests which I don't want to use.
I also found that I can edit my .coveragerc file and omit files and functions, when running my tests using intellij (with unittest framework), it didn't manage to use .coveragerc file.
Any idea how to ignore / omit / exclude files during test coverage ?
How can I run the test using this file as a parameter ?
You can use this command in your .coveragerc file.
# .coveragerc
[report]
show_missing = True
omit =
junk/*
You include the path of files you want to omit under the omit command, for example, I want to omit every file in the junk folder hence my use of junk/*.
To add to proton's answer.
You can also use the # pragma: no cover commenting specific clauses. You can comment every clause in a file to exclude the content of the file. This is more tedious but gives you finer control if you want to partially ignore a file.
Here is a link to the coverage.py project that discuses coverage exclusion in further detail:
https://coverage.readthedocs.io/en/7.0.0/excluding.html
I would have commented on proton's answer instead of making a new answer, but I do not have enough reputation. More so, I would have suggested an edit, but there are too many pending edits and stack-overflow will not let me add another.

PyCharm3 Live template not working at all

I just switched from Eclipse/PyDev to PyCharm 3 CE. I can't get the live templates working any ways. Followed every documentation I can find online like this:
http://www.jetbrains.com/pycharm/webhelp/live-templates.html
And the builtin python template super(Generates a 'super' call) does not work either.
By "not working", I meant that when editing a python file in PyCharm and typing the abbreviation, the popup snippets list does not include the live templates, even though they are under the Python template group.
Am I missing something?
I am using PyCharm 3.1 Professional (evaluation version) and am having the same issue.
However, using Ctrl+J will bring up templates as will Code -> Insert Live Template. It is also possible to start typing a code snippet and then press Ctrl+J to see a filtered list of templates.
Don't forget to also select the "context"...

Categories

Resources