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

Avoid naive datetimes #11

Open
GitRon opened this issue Dec 11, 2024 · 5 comments
Open

Avoid naive datetimes #11

GitRon opened this issue Dec 11, 2024 · 5 comments

Comments

@GitRon
Copy link
Contributor

GitRon commented Dec 11, 2024

  def visit_Call(self, node):
        # Prüfen, ob die Funktion "datetime" aufgerufen wird
        if isinstance(node.func, ast.Attribute) and node.func.attr == "datetime":
            # Überprüfen, ob kein "tzinfo" Argument gesetzt wurde
            tzinfo_arg = any(
                kw.arg == "tzinfo" and not kw.value
                for kw in node.keywords
            )
            if not tzinfo_arg:
                self.naive_datetimes.append((node.lineno, node.col_offset))
        self.generic_visit(node)
@mariusburfey
Copy link

Auch wenn es diese Regel hier noch nicht gibt, meckert irgendwas in meinem Tooling, wenn ich das tue. Soll ich mal suchen, was das ist?

@GitRon
Copy link
Contributor Author

GitRon commented Dec 11, 2024

Bitte.

@mariusburfey
Copy link

https://docs.astral.sh/ruff/rules/call-datetime-without-tzinfo/
Ruff mit allen Regeln findet schon viel. ;)

@GitRon
Copy link
Contributor Author

GitRon commented Dec 11, 2024

Dann zu. Danke!

@GitRon GitRon closed this as completed Dec 11, 2024
@GitRon GitRon reopened this Dec 11, 2024
@GitRon
Copy link
Contributor Author

GitRon commented Dec 11, 2024

Scheinbar kann man das irgendwie umgehen. Ich recherchiere.

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

No branches or pull requests

2 participants