Skip to content

Add a new user/beginner friendly errors system#505

Draft
NiumXp wants to merge 16 commits into42school:masterfrom
NiumXp:newerrors
Draft

Add a new user/beginner friendly errors system#505
NiumXp wants to merge 16 commits into42school:masterfrom
NiumXp:newerrors

Conversation

@NiumXp
Copy link
Contributor

@NiumXp NiumXp commented Jul 1, 2024

Hi, this is one of my drafts (maybe 7 months ago) focused on beginners (and quality of life) that I wrote for norminette when @matthieu42Network was accepting my PRs, I'm not sure if he's still available, but recently it seems like new people became collaborators, this made me happy and willing to continue with contributions.

New errors formatting

To use the new format is not necessary a new configuration, just run your norminette:

(.venv) niumxp@DESKTOP-LRN507C:~/oss/norminette$ cat -A test.c
#define exit 42$
$
int^IMain(void) {$
^Ireturn exit;$
}$
(.venv) niumxp@DESKTOP-LRN507C:~/oss/norminette$ norminette test.c
test.c:1:1 INVALID_HEADER Missing or invalid 42 header
test.c:1:9 MACRO_NAME_CAPITAL
     1 | #define exit 42
       |         ^^^^ Macro name must be capitalized
test.c:3:5 FORBIDDEN_CHAR_NAME
     3 | int Main(void) {
       |     ^^^^ user defined identifiers should contain only lowercase characters, digits or '_'
test.c:3:16 BRACE_NEWLINE
     3 | int Main(void) {
       |                ^ Expected newline before brace
test.c:4:12 RETURN_PARENTHESIS
     4 |     return exit;
       |            ^^^^ Return value must be in parenthesis

I added a red color to the errors:
image

@dynpatch
Copy link

Subjective nit, this should probably have a bit more padding for readability's sake. Other than that, looks pretty amazing :)

Copy link

@otto-mata otto-mata left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall a very good new feature, the norminette would really benefit from its addition!
Some changes are still necessary in my opinion, but please you are absolutely free to discuss your choices!

Bests,
tblochet

Comment on lines +98 to +100
# if len(item) == 2:
# lineno, column = item
# return self._line_to_index[lineno + column]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary comments

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See last comment, potentially breaking change

from norminette.errors import Error, Errors, Highlight as H
from norminette.errors import HumanizedErrorsFormatter
from norminette.errors import ShortErrorsFormatter
# from norminette.errors import HumanizedErrorsFormatter

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary comment

Copy link
Collaborator

@Asandolo Asandolo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello can you tell us if this PR is still relevant, if is it can you rebase and resolve all conflict ?

Have a nice day

@NiumXp
Copy link
Contributor Author

NiumXp commented Jun 6, 2025

Hello, @Asandolo!

Thanks for checking in. Yep, this PR is still relevant! I’ll take care of the rebase and sort out the conflicts shortly.

Really appreciate you reaching out. Hope your day’s going well!

@NiumXp NiumXp marked this pull request as draft June 7, 2025 23:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

Comments