SyntaxError: Invalid syntax

I have formatted your code, you can compare with below, single , double, triple quote with yours

Python don’t need semicolon at the end.
Edit:

def validate(self):
	if self.from_time > self.to_time:
		frappe.throw(_("Start Date cannot be after End Date"))

	existing_records=frappe.db.sql(""" select name from `tabMeeting Schedule` where from_time>='{0}' and 
		to_time<='{1}' """.format(self.from_date,self.from_date), as_list=True)
	if existing_records:
		frappe.msgprint("Sorry! please try again meeting exist already on this date ")
	else:
		frappe.msgprint("Congratulation! Schedule Success!")

Hi @magic-overflow

I still receive same error.

Thanks.

Regards,
@Foxdemon96

Can you print-screen your code again?

hello @magic-overflow

Thanks.

Regards,
@Foxdemon96

After you made change, have you restarted bench?

Hello @magic-overflow

I already restartded bench and clear cache just in case.

Regards,
@Foxdemon96

Wrong indentation at existing_records = frappe.db.sql …

it should be in the same line as the frappe.throw statement

Just press a tab and it should be done.

Hello @root13F

Do you mean this

def validate(self):
	if self.from_time > self.to_time:
		frappe.throw(_("Start Date cannot be after End Date"))
		existing_records=frappe.db.sql(""" select name from `tabMeeting Schedule` where from_time>='{0}' and 
		to_time<='{1}' """.format(self.from_time,self.from_time), as_list=True)
	if existing_records:
		frappe.msgprint("Sorry! please try again meeting exist already on this date ")
	else:
		frappe.msgprint("Congratulation! Schedule Success!")

Thanks.

Regards,
@Foxdemon96

Yes. Now it should be okay

when from_time is bigger than to_time, then throw error. Statement under frappe.throw is never be called. Am i right?

oh yes my suggestion is wrong.

@Foxdemon96 what you did was correct you can revert the indent to as it was

Hi @root13F and @magic-overflow,

Sorry but I don’t get it.

Thanks.

Regards,
@Foxdemon96

if you got same error, please update your code as following (testing purpose) whether it still has error

def validate(self):
	if self.from_time > self.to_time:
		frappe.throw(_("Start Date cannot be after End Date"))

	existing_records = {}
	if existing_records:
		frappe.msgprint("Sorry! please try again meeting exist already on this date ")
	else:
		frappe.msgprint("Congratulation! Schedule Success!")

Hello @magic-overflow

I Still receive error

Traceback (most recent call last):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/app.py", line 62, in application
    response = frappe.handler.handle()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 22, in handle
    data = execute_cmd(cmd)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 53, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 939, in call
    return fn(*args, **newargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/desk/form/load.py", line 71, in getdoctype
    docs = get_meta_bundle(doctype)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/desk/form/load.py", line 81, in get_meta_bundle
    bundle = [frappe.desk.form.meta.get_meta(doctype)]
  File "/home/frappe/frappe-bench/apps/frappe/frappe/desk/form/meta.py", line 24, in get_meta
    meta = FormMeta(doctype)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/desk/form/meta.py", line 34, in __init__
    self.load_assets()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/desk/form/meta.py", line 44, in load_assets
    self.load_templates()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/desk/form/meta.py", line 159, in load_templates
    module = load_doctype_module(self.name)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/utils.py", line 185, in load_doctype_module
    doctype_python_modules[key] = frappe.get_module(module_name)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 704, in get_module
    return importlib.import_module(modulename)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/home/frappe/frappe-bench/apps/meeting/meeting/meeting/doctype/meeting/meeting.py", line 22
    existing_records = {}
                   ^
SyntaxError: invalid syntax

Thanks.

Regards,
@Foxdemon96

It’s so weird. I really got no ideas. Can you delete the whole line which is error? And type a new variable name.

Hello @magic-overflow

I try this plus adding new code and no error it was success

but when I add

I receive tabMeeting Schedule doesn’t exist

Thanks.

Regards,
@Foxdemon96

Can u check if ur code is same as image below?

Hello @magic-overflow

Yes. same as on image.

Regards,
@Foxdemon96

Is it syntax or logic error? share me your trace-back error

Hello @magic-overflow

I used tabMeeting

then no error persist.

but the problem is

if existing_records detected frappe.msgprint("Sorry! please try again meeting already exist on this date ")

it must never be safe unless there’s no existing_records detected.

Sorry for my grammar :smiley:

Thanks,
@Foxdemon96