Find duplicate blocks of code in a Python file [closed] - python

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 months ago.
Improve this question
is there a way to get warnings for duplicate blocks/lines of code in the same file for Python using pylint or flake8?
I am aware that for pylint R0801 warns of duplicate code in different files, but I'd also like to get a warning if there is a significant (i.e. > 3 consecutive lines) code duplication within the same file.
For Flake8 I was not able to find that functionality at all (maybe through a plugin?)
Edit: need this for GitLab CI/CD integration, so functionality in an IDE like PyCharm is not an option.

Finding duplicate code within the same Python file is supported by a static code analysers, such as PyCharm, Flake8, and mypy.
Here is more info about this feature in PyCharm.

Related

View Python source code of the standard library and external libraries [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 3 years ago.
Improve this question
How can I view the source code of a particular Standard Library and/or an External Library? I would like to see the Python code, not the underling C code.
I am trying to find this to see how experienced programmers write their code. I already looked at the Where do I find the python standard library code? but the answer just seems to be most is written in C.
The main repo of the standard library is hosted here: https://github.com/python/cpython/blob/3.7/Lib/
This can also be found on the typical Python installation in the same location (i.e. subfolder Lib).

What is the alternative for slimmer in Python 3? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
I've been using slimmer in python 2 but now I'm switching to Python3. I am not able to find alternative to slimmer in Python3. Can anyone suggest any alternative which can be used in Python3? Thanks
Slimmer is no longer maintained, as stated by the author on the Project's page, so it is very unlikely that it gets ported to Python 3 one day.
The author recommends using other projects (he mentions UGLIFY-JS or CSSMIN) that are not Python based (most "uglyfiers" are written in JS).
That makes it likely that, to use them from Python code, you will have to use a subprocess.Popen() call to their executable. You can create a wrapper function around this call to create a kind of Python binding.

Is there any python IDE that supports "highlight and run"? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
I used to be a heavy R programmer and really used to the Rstudio's "highlight and run" feature. I just wonder if there any python IDE that has similar feature that allows you to select part of the code in a script and run and show the results in a console?
In Spyder you can highlight and run by pressing F9. I also heard a rumour that RStudio is going to be able to run python soon but I'm not sure if it's true
Try GNU Emacs - very powerful text editor. Using this editor you can run the selected region of code in the python shell. See this question for more details.

How to check pep8 standards in my code [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
i am developing a python library with couple of modules and files. I have read through the pep8 rules given in the below link
https://www.python.org/dev/peps/pep-0008/
Is there any package or software available which can check the python styles and structure .
for example , indendation with spaces or tabs , variable conventions etc.
I am looking for a module which can perform this task..
The term for this is "linting". A python module called Pylint is available.
It checks for coding standards and errors with full customizability. It can be run from the command line, as part of a continuous integration workflow, integrated into various IDEs.

SonarSource Python alternative? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
We are planing to place quality checking for our python code, earlier we used sonar for java projects. Is there any project support python having similar functionality of sonarsource ?
There seem to exist a python plugin for sonar now.
Check this https://stackoverflow.com/questions/296420/automatic-code-quality-review-tool-for-python
Basically you could use PyFlakes, PyLint or PEP8 and hook it to your version control system to run on every commit.
You may have a look at Violations Lib. It is used in a bunch of plugins, listed in its README. It supports analysis tools for Python and there are plugins for commenting GitLab, Bitbucket Server and GitHub.

Categories