Skip to content
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

[Feature Request] a new lint rule to require that each block must end with ... (Ellipsis) or #. (HashtagDot) or a new line. #9685

Closed
EdSaleh opened this issue Jun 3, 2024 · 5 comments
Labels
Duplicate 🐫 Duplicate of an already existing issue

Comments

@EdSaleh
Copy link

EdSaleh commented Jun 3, 2024

Current problem

[Feature] new lint rule to require a comment #. at end each python block.

Desired solution

Hello,

Please create a new lint rule to require that each block must end with ... or #. or a new line.
This would work as a curly braces blocks found in C style languages.
Also, this could also be used to reformat python code by code editor to fix any indentation issues.

Users can also use a different word symbol or use a new line for this purpose. (..., #., newline, etc). The user has the option to select the keyword they would like to have for the project. The difference between this proposal (:\n code_block \n#.) and curly braces ({}) in C languages is that curly braces are also indentation insensitive while this proposal is indentation sensitive just like indentation style languages.

There could also be a configurable threshold limit for block lines for which the code_block_ending_marker rule is activated and would apply (example: block_lines > 1 lines by default).
Users can also use new line instead of # or #. by configuring code_block_ending_marker_word if it fits their project development.

Example:

import string
def atbash(sequence: str) -> str:
    """
    Example
    """
    output = ""
    for i in sequence:
        extract = ord(i)
        if 65 <= extract <= 90:
            output += chr(155 - extract)
        #.
        elif 97 <= extract <= 122:
            output += chr(219 - extract)
        #.
        else:
            output += i
        #.
    #.
    return output
#.

There are cases where strict block guarantees is required. Also, when copying python code sometimes spacing is not aligned correctly and having code with this style with editor support, editor would fix incorrect spacing easily.

if(True):
print(True)
print(True)
...
if(True):
print(True)
print(True)
...

OR

if(True):
print(True)
print(True)
#.
if(True):
print(True)
print(True)
#.

would be aligned correctly by the editor to:

if(True):
 print(True)
 print(True)
...
if(True):
 print(True)
 print(True)
...

OR

if(True):
 print(True)
 print(True)
#.
if(True):
 print(True)
 print(True)
#.

Thank you,

Additional context

No response

@EdSaleh EdSaleh added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Jun 3, 2024
@EdSaleh EdSaleh changed the title [Feature] new lint rule to require a comment #. at end each python block. [Feature] new lint rule to require a comment #. (or #/, new line) at end each python block. Jun 3, 2024
@Pierre-Sassoulas Pierre-Sassoulas added Duplicate 🐫 Duplicate of an already existing issue and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Jun 3, 2024
@Pierre-Sassoulas
Copy link
Member

Please don't reopen closed issues.

@EdSaleh
Copy link
Author

EdSaleh commented Jun 4, 2024

Please don't reopen closed issues.

@Pierre-Sassoulas
I added new info to the topic.
The purpose of this issue is to let python and other language developers know of this idea and to create a discussion around it, discussion to identify whether this feature could be useful or not and why, and the decision around it is for the project developers to choose.

I have also contributed to rust lint previously and my proposal was completed and merged.
rust-lang/rust-clippy#2685

As suggested, I will be looking into creating a plugin for this feature.

@DanielNoord
Copy link
Collaborator

DanielNoord commented Jun 4, 2024

You did not contribute, it was written by somebody else, and the largest discussion in that PR was about how to correctly phrase why it was such a bad lint (rust-lang/rust-clippy#3494).

I also see you link to that issue in various other repositories (modularml/mojo#2929 and astral-sh/ruff#11698) where you have received similar negative responses. To keep all open source maintainers from going insane and spending too much time on your unnecessary issues and comments consider this your last warning before I ban you from this organisation and report you for spamming various repositories.

Read up on tools your opening issues against, see what they design philosophy is and act like the maintainers ask you to.

Good luck with writing your plugin! I hope to see it on PyPI one day 😄

@EdSaleh
Copy link
Author

EdSaleh commented Jun 4, 2024

You did not contribute, it was written by somebody else, and the largest discussion in that PR was about how to correctly phrase why it was such a bad lint (rust-lang/rust-clippy#3494).

I also see you link to that issue in various other repositories (modularml/mojo#2929 and astral-sh/ruff#11698) where you have received similar negative responses. To keep all open source maintainers from going insane and spending too much time on your unnecessary issues and comments consider this your last warning before I ban you from this organisation and report you for spamming various repositories.

Read up on tools your opening issues against, see what they design philosophy is and act like the maintainers ask you to.

Good luck with writing your plugin! I hope to see it on PyPI one day 😄

I posted the proposal to different project since I see it could be useful for these projects as well, with similar indentation code block code style, and an average person knows the difference between spamming and discussing.

My rust lint proposal is the older and first one, and it's marked completed and merged as stated on the issue. I didn't code it though. Let's continue with pylint here. As I said, I am looking into implementing a plugin for this feature.

@EdSaleh
Copy link
Author

EdSaleh commented Jun 4, 2024

You did not contribute, it was written by somebody else, and the largest discussion in that PR was about how to correctly phrase why it was such a bad lint (rust-lang/rust-clippy#3494).

I also see you link to that issue in various other repositories (modularml/mojo#2929 and astral-sh/ruff#11698) where you have received similar negative responses. To keep all open source maintainers from going insane and spending too much time on your unnecessary issues and comments consider this your last warning before I ban you from this organisation and report you for spamming various repositories.

Read up on tools your opening issues against, see what they design philosophy is and act like the maintainers ask you to.

Good luck with writing your plugin! I hope to see it on PyPI one day 😄

Hello,
I'm not sure why would you deal funnily or sarcastically with this proposal (hashdot for indentation code block). This is not a good environment for proposals or new ideas. I am just proposing an idea that I think could be helpful for some people, particularly people coming for C style languages, while following python syntax and conventions and it's your decision at the end whether to accept it or not for this proposal.
I think python, particularly its syntax is an amazing language for nearly everything as it's the nearest to natural language and that's the reason for its wide spread use in many fields.
Finally, my proposal is complete now, and there aren't anything more to add to it or any discussion regarding it.
Thank you,

@EdSaleh EdSaleh changed the title [Feature] new lint rule to require a comment #. (or #/, new line) at end each python block. [Feature] new lint rule to require a comment #.(hashdot) (or #/, new line) at end each python block. Jun 4, 2024
@EdSaleh EdSaleh changed the title [Feature] new lint rule to require a comment #.(hashdot) (or #/, new line) at end each python block. [Feature] new lint rule to require a comment #. (hashdot) (or #/, new line) at end each python block. Jun 4, 2024
@EdSaleh EdSaleh changed the title [Feature] new lint rule to require a comment #. (hashdot) (or #/, new line) at end each python block. [Feature] new lint rule to require a comment #. (hashdot) (or #/, new line) at end each python block. And new lint rule for declaring variables to have #declare or #var comment. Jun 5, 2024
@EdSaleh EdSaleh changed the title [Feature] new lint rule to require a comment #. (hashdot) (or #/, new line) at end each python block. And new lint rule for declaring variables to have #declare or #var comment. [Feature Request] new lint rule to require a comment #. (hashdot) (or #/, new line) at end each python block. And new lint rule for declaring variables to have #declare or #var comment. Jun 5, 2024
@EdSaleh EdSaleh changed the title [Feature Request] new lint rule to require a comment #. (hashdot) (or #/, new line) at end each python block. And new lint rule for declaring variables to have #declare or #var comment. [Feature Request] new lint rule to require a comment #. (HashtagDot) (or #/, new line) at end each python block. And new lint rule for declaring variables to have #declare or #var comment. Jun 7, 2024
@EdSaleh EdSaleh changed the title [Feature Request] new lint rule to require a comment #. (HashtagDot) (or #/, new line) at end each python block. And new lint rule for declaring variables to have #declare or #var comment. [Feature Request] a new lint rule to require that each block must end with ... (Ellipsis) or #. (HashtagDot) or a new line. Jul 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate 🐫 Duplicate of an already existing issue
Projects
None yet
Development

No branches or pull requests

3 participants